A Pen by Carlos Rojas on CodePen.
Created
July 31, 2015 21:20
-
-
Save carlosrojaso/22043a1b26146704c2fb to your computer and use it in GitHub Desktop.
bdOBeG
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
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