pace
pace copied to clipboard
Track $http requests in angularjs?
Hey All,
I'm trying to get pace to work with my angularjs app. Everything works fine with page loads but when I make a $http call pace doesn't show the progress. Any ideas?
I tried using this library but it isn't as configurable as I would like, it does however with with $http. https://github.com/chieffancypants/angular-loading-bar
Thanks, Tom
I am using Pace with an Angular app. Try using these options, by placing them before your pace/third-party js script references:
window.paceOptions = {
ajax: {
trackMethods: ["GET", "POST"],
trackWebSockets: false
},
document: false,
restartOnPushState: false
};
trackMethods
can take all the verbs you need. Shove in "DELETE", etc. if you need them.
trackWebSockets
is off for me because I use LiveReload. Visual Studio Browserlink will also cause pace to load forever.
document
is false, because I care more about XHR loads.
restartOnPushState
is also false for the same reason as document
. I only care about the loads from XHR requests.
Good luck!
It works for me. Try loading the following options before including the pace.js
window.paceOptions = {
document: true, // disabled
eventLag: true,
restartOnPushState: true,
restartOnRequestAfter: true,
ajax: {
trackMethods: [ 'POST','GET']
}
};
I only tested @AbhiPanda 's solution and it worked for me.
Thank you all. It's worked for me too
Me too! Thank you @abhipanda
How to make it work on Angular2, using http.get and so on?
where should i put this code :(
@abhipanda thanks buddy
This question should not be an issue. I have created a stackoverflow question to answer the same. Please use it for further discussions.
http://stackoverflow.com/questions/42236286/pace-track-http-requests-in-angularjs
@abhipanda Thanks! saved my day!
@abhipanda thanks! But I have a question... I work with Angular 6 and Typescript, but run a function in mi TS, pace not work for that... yo have any idea?
@abhipanda 's example still works for AngularJS v1.7.8. Thanks!