Created
September 14, 2014 11:47
-
-
Save fisshy/7b5db0bc7bb74719486d to your computer and use it in GitHub Desktop.
Http Interceptor for Angular JS
This file contains 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
angular.module('model').factory('httpMiddletier', | |
function ($q, $rootScope) { | |
return { | |
request: function (config) { | |
$rootScope.loading = true; | |
return config || $q.when(config); | |
}, | |
requestError: function (rejection) { | |
$rootScope.loading = false; | |
return $q.reject(rejection); | |
}, | |
response: function (response) { | |
$rootScope.loading = false; | |
return response || $q.when(response); | |
}, | |
responseError: function (rejection) { | |
$rootScope.loading = false; | |
return $q.reject(rejection); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment