A service that allow to display a progress bar depending on http get requests.
When the progress-bar-service is listening, a progress bar element appears and is loading until all http get requests are finished.
Can specify the parent element on the initialisation.
Add http interceptor in your module config method :
angular.module('demo').config(function($httpProvider) {
$httpProvider.interceptors.push("luiHttpInterceptor");
});
Add progress bar in your module run method :
angular.module("myApp").config(fumction(luisConfigProvider){
luisConfigProvider.setConfig({
parentTagIdClass: "demo",
prefix: "lui",
});
});
Specify when you want to listen http request. For example, we can do that each time the ui-router state change :
// with ui-router
$scope.$on("$stateChangeStart", function(event, toState, toParams, fromState, fromParams) => {
luisProgressBar.startListening();
});
// with ngRoute
$scope.$on("$routeChangeStart", function(event, toState, toParams, fromState, fromParams) => {
luisProgressBar.startListening();
});
You can specify what http methods you want to listen to.
luisProgressBar.startListening(); // will listen to get requests luisProgressBar.startListening(["POST", "PUT"]); // will only listen to post and put request
A progress bar has been added to the page and will reload at a state change.
Clicking will make the progress bar reappear and load quickly
Clicking will make the progress bar reappear and load slowly
Or click here to change the color of the progress bar