mailApp.js
1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
/**
* @ngdoc overview
* @name newappApp
* @description
* # newappApp
*
* Main module of the application.
*/
var MakeMailApp = angular
.module('newApp', [
'ngAnimate',
'ngRoute',
'ngTouch',
'ui.bootstrap'
])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'mailbox/mailbox.html',
controller: 'mailboxCtrl'
})
.when('/send', {
templateUrl: 'mailbox/mailbox-send.html',
controller: 'mailSendCtrl'
}).otherwise({
redirectTo: '/'
});
});
// Route State Load Spinner(used on page or content load)
MakeMailApp.directive('ngSpinnerLoader', ['$rootScope',
function($rootScope) {
return {
link: function(scope, element, attrs) {
// by defult hide the spinner bar
element.addClass('hide'); // hide spinner bar by default
// display the spinner bar whenever the route changes(the content part started loading)
$rootScope.$on('$routeChangeStart', function() {
element.removeClass('hide'); // show spinner bar
});
// hide the spinner bar on rounte change success(after the content loaded)
$rootScope.$on('$routeChangeSuccess', function() {
setTimeout(function(){
element.addClass('hide'); // hide spinner bar
},500);
$("html, body").animate({
scrollTop: 0
}, 500);
});
}
};
}
])