Created
October 8, 2013 04:23
-
-
Save clouddueling/6879422 to your computer and use it in GitHub Desktop.
Show a loading indicator angular js for ajax
This file contains 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
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