-
-
Save ev0k3r/6039016 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| KK.factory('httploadingInterceptor',['$q','$rootScope', function ($q, $rootScope) { | |
| return function (promise) { | |
| $rootScope.loading = true; | |
| return promise.then(function (response) { | |
| // hide the spinner | |
| $rootScope.loading = false; | |
| return response; | |
| }, function (response) { | |
| // hide the spinner | |
| //$rootScope.loading = false; | |
| return $q.reject(response); | |
| }); | |
| }; | |
| }]); | |
| /* Example how to use it | |
| KK.config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider) { | |
| //set loading interceptor | |
| $httpProvider.responseInterceptors.push('httpResponseInterceptor'); | |
| }]); | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment