You can achieve this with interceptors. Example:
myapp.config(function($httpProvider) { var myInterceptor = ['$rootScope','$q', function(scope, $q) { function onSuccess(response) { return response; } function onError(response) { return $q.reject(response); } return function(promise) { return promise.then(onSuccess, onError); }; }]; $httpProvider.responseInterceptors.push(myInterceptor); });
This will capture all of your angular $ http and $ resource calls and raise onError or onSuccess before continuing with your custom callbacks.
source share