Skip to content

Instantly share code, notes, and snippets.

@clouddueling
Created October 8, 2013 04:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save clouddueling/6879422 to your computer and use it in GitHub Desktop.
Save clouddueling/6879422 to your computer and use it in GitHub Desktop.
Show a loading indicator angular js for ajax
app.config(function($routeProvider, $httpProvider) {
var numLoadings = 0,
loadingScreen = $('.processing');
$httpProvider.interceptors.push(function() {
return {
request: function(config) {
++numLoadings;
loadingScreen.show();
return config;
},
response: function(response) {
--numLoadings;
if (numLoadings == 0)
loadingScreen.hide();
return response;
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment