Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ionic loading screen intercepting http calls
// Ionic loading page
.run(function ($rootScope, $ionicLoading) {
$rootScope.$on('loading:show', function() {
$ionicLoading.show({template: 'foo'});
});
$rootScope.$on('loading:hide', function() {
$ionicLoading.hide();
});
})
.config(function($httpProvider) {
$httpProvider.interceptors.push(function($rootScope) {
return {
request: function(config) {
$rootScope.$broadcast('loading:show');
return config;
},
response: function(response) {
$rootScope.$broadcast('loading:hide');
return response;
}
};
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.