pace icon indicating copy to clipboard operation
pace copied to clipboard

Track $http requests in angularjs?

Open wootwoot1234 opened this issue 10 years ago • 12 comments

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

wootwoot1234 avatar Aug 23 '14 19:08 wootwoot1234

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!

ashclarke avatar Oct 22 '14 16:10 ashclarke

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']
    }

};

abhipanda avatar Mar 10 '15 22:03 abhipanda

I only tested @AbhiPanda 's solution and it worked for me.

Alain1405 avatar Dec 18 '15 19:12 Alain1405

Thank you all. It's worked for me too

abhilashpullelil avatar May 03 '16 04:05 abhilashpullelil

Me too! Thank you @abhipanda

danielemontecchi avatar Jul 07 '16 14:07 danielemontecchi

How to make it work on Angular2, using http.get and so on?

igordeoliveirasa avatar Jul 27 '16 13:07 igordeoliveirasa

where should i put this code :(

matt212 avatar Dec 27 '16 12:12 matt212

@abhipanda thanks buddy

nirav2410 avatar Feb 14 '17 15:02 nirav2410

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 avatar Feb 14 '17 21:02 abhipanda

@abhipanda Thanks! saved my day!

rauwebieten avatar Jul 30 '18 09:07 rauwebieten

@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?

al3xinh0 avatar Aug 21 '18 14:08 al3xinh0

@abhipanda 's example still works for AngularJS v1.7.8. Thanks!

ktsalik avatar Apr 12 '19 07:04 ktsalik