How to cancel RestAngular promise .then ()?

How to cancel RestAngular promise .then ()? I'm not sure how to cancel the promise / xhr request in restangular / $ http - it's pretty simple in jQuery.

+3
source share
1 answer

You can interrupt calls $httpusing the configuration property timeout, which can be a promise that interrupts the request when it is resolved.

So in restangular you can do this for example

var abort = $q.defer();
Restangular.one('foos', 12345).withHttpConfig({timeout: abort.promise}).get();
abort.resolve();

Hope this helps!

+2
source

All Articles