-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (35 loc) · 916 Bytes
/
index.js
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
var cacheWatch = angular.module('cachewatch', ['ng']);
cacheWatch.service('cachewatch', ['$rootScope', function ($rootScope) {
var _getTopScope = function() {
return $rootScope;
//return angular.element(document).scope();
};
$rootScope.ready = function() {
var $scope = _getTopScope();
$scope.status = 'ready';
if(!$scope.$$phase) $scope.$apply();
};
$rootScope.loading = function() {
var $scope = _getTopScope();
$scope.status = 'loading';
if(!$scope.$$phase) $scope.$apply();
};
$rootScope.$on('$routeChangeStart', function() {
_getTopScope().loading();
});
return {
ready : $rootScope.ready,
loading : $rootScope.loading
};
}]);
cacheWatch.directive('body', [function (){
return {
restrict : 'E',
link : function (scope, element) {
var ele = angular.element(element);
scope.$watch('status', function(status){
ele.attr('data-ready', status);
});
}
}
}]);