Skip to content

Instantly share code, notes, and snippets.

@carlosrojaso
Created July 31, 2015 21:20
Show Gist options
  • Save carlosrojaso/22043a1b26146704c2fb to your computer and use it in GitHub Desktop.
Save carlosrojaso/22043a1b26146704c2fb to your computer and use it in GitHub Desktop.
bdOBeG
angular.module('App')
.factory('TrendicityInterceptor', function ($injector, $q) {
var hideLoadingModalIfNecessary = function() { var $http = $http || $injector.get('$http'); if ($http.pendingRequests.length === 0) {
$injector.get('$ionicLoading').hide();
}
};
return {
request: function(config) {
$injector.get('$ionicLoading').show();
},
requestError: function(rejection) { hideLoadingModalIfNecessary(); return $q.reject(rejection);
},
response: function(response) {
hideLoadingModalIfNecessary();
return response; },
responseError: function(rejection) { hideLoadingModalIfNecessary(); return $q.reject(rejection);
} };
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment