0

I want to make a progress bar directive for my angular app, which shouldn't be too bad. However, how would I determine the progress of http requests? Would I need to restructure the existing server code for this?

I have one progress bar that works relatively well right now and its because the angular-file-upload plugin I am using for that one case has a progress api.

For my other cases I'm using an interval to increase the progress and just let it idle at 50% until my request comes back. This works but is hacky since it'll have a huge jump from 50-100. Is there a way I can just get the actual progress of these requests?

EDIT: actually, this probably isn't possible because the progress events are for the actual requests right? It won't be the progress of the tasks being completed on the server. Would I have to keep sending back to my angular app from the server? Like after I parse some data i'll send 10% progress back then another update after the next task in the series of task is done? Is this some kind of pub/sub?

user6728767
  • 1,123
  • 3
  • 15
  • 31
  • https://angular.io/guide/http#listening-to-progress-events –  Jan 11 '18 at 20:23
  • What are the other cases where you are trying to determine progress of HTTP requests? – guest271314 Jan 11 '18 at 20:25
  • I'd encourage you to check out [angular-loading-bar](http://chieffancypants.github.io/angular-loading-bar/) before considering making your own - this one is quite robust – scniro Jan 11 '18 at 20:29
  • The other cases i'm using it for our publishing code and our language translation part, both of which get sent to the server to be completed. If I'm using restangular for those requests, can I wrap the angular api around it for the progress events? angular-loading-bar would still require me to get the progress for it to increment the bar right? – user6728767 Jan 11 '18 at 20:56
  • Is the angular.io for the latest version of angular? We are still using angular 1 – user6728767 Jan 11 '18 at 21:10
  • Possible duplicate of [Angular 1.5.4 $http progress event](https://stackoverflow.com/questions/36622826/angular-1-5-4-http-progress-event) – Joe Hawkins Jan 11 '18 at 21:13
  • @user6728767 Yep, angular.io is for Angular 2+ [AngularJS.org](https://angularjs.org) is for AngularJS (1.x). Unfortunately you're limited to two events... success and error though – phuzi Jan 11 '18 at 21:25

0 Answers0