<script type="text/javascript" src="/vendor/angular-spinner/angular-spinner.js"></script>
.factory('httpInterceptor', function ($q,usSpinnerService, $rootScope, $log) {
var numLoadings = 0;
return {
request: function (config) {
numLoadings++;
// Show loader
// $rootScope.$broadcast("loading-started");
usSpinnerService.spin('spinner-1');
return config || $q.when(config)
},
response: function (response) {
if ((--numLoadings) === 0) {
// Hide loader
// $rootScope.$broadcast("loading-complete");
usSpinnerService.stop('spinner-1');
}
return response || $q.when(response);
},
responseError: function (response) {
if (!(--numLoadings)) {
// Hide loader
// $rootScope.$broadcast("loading-complete");
usSpinnerService.stop('spinner-1');
}
return $q.reject(response);
}
};
})
.config(function ($httpProvider) {
$httpProvider.interceptors.push('httpInterceptor');
})
댓글
댓글 쓰기