forked from adonespitogo/angular-loading-spinner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-loading-spinner.js
More file actions
26 lines (24 loc) · 865 Bytes
/
angular-loading-spinner.js
File metadata and controls
26 lines (24 loc) · 865 Bytes
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
(function(){
angular.module('ngLoadingSpinner', ['angularSpinner'])
.directive('usSpinner', ['$http', '$rootScope' ,function ($http, $rootScope){
return {
link: function (scope, elm, attrs)
{
if(attrs.$attr.usSpinnerStandalone) return;
$rootScope.spinnerActive = false;
scope.isLoading = function () {
return $http.pendingRequests.length > 0;
};
scope.$watch(scope.isLoading, function (loading)
{
$rootScope.spinnerActive = loading;
if(loading){
elm.removeClass('ng-hide');
}else{
elm.addClass('ng-hide');
}
});
}
};
}]);
}).call(this);