I'm using angular-loading-bar <https://github.com/chieffancypants/angular-loading-bar> in my AngularJS application that is used when `*$http*` request is made,
I have a scenario where there are series of `*$http*` requests and I need to show the loading bar before starting the first request and end it after the end of last request. I have done this by using `*ignoreLoadingBar*` to true and `*cfpLoadingBar.start()*` and `*cfpLoadingBar.complete()*` as per their api <https://github.com/chieffancypants/angular-loading-bar#service-api-advanced-usage> $http.post(<url>, $scope.options,{ignoreLoadingBar:true}) Next what I want is to handle the loading bar by percentage using function cfpLoadingBar.set(percentage) I set the percentage by *current_request/total_requests*, (let say 2/5 i.e. 40%) but what happens, it starts the loading bar and increases the bar with random `*cfpLoadingBar.inc()*` calls and take the bar to more than 50% before the first request completes, and when I call `*cfpLoadingBar.set()*` after first request it take it back to %20 and again get to more than 60% before second request and take it back to %40 after second request completes and so on. What I'm thinking of is to override the `*_inc*` function in my controller so I can handle it /** * Increments the loading bar by a random amount * but slows down as it progresses */ function _inc() { if (_status() >= 1) { return; } var rnd = 0; // TODO: do this mathmatically instead of through conditions var stat = _status(); if (stat >= 0 && stat < 0.25) { // Start out between 3 - 6% increments rnd = (Math.random() * (5 - 3 + 1) + 3) / 100; } else if (stat >= 0.25 && stat < 0.65) { // increment between 0 - 3% rnd = (Math.random() * 3) / 100; } else if (stat >= 0.65 && stat < 0.9) { // increment between 0 - 2% rnd = (Math.random() * 2) / 100; } else if (stat >= 0.9 && stat < 0.99) { // finally, increment it .5 % rnd = 0.005; } else { // after 99%, don't increment: rnd = 0; } var pct = _status() + rnd; _set(pct); } https://github.com/chieffancypants/angular-loading-bar/blob/master/build/loading-bar.js#L239 and make increment by giving it an argument? -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
