Dániel Kis Dániel Kis - 4 months ago 62
TypeScript Question

Cancel http request

In jQuery ajax there's a way to abort ajax queries:

var xhr = $.ajax({ ... });

when user wants to abort the operation or navigates to other page in a single page app I can call


In angular2-http api I cannot find any possibility to abort the query as it uses rxjs.

Is there a way to abort the ajax query in angular2?


When you subscribe, you get a subscription you can use to unsubscribe

this.httpSubscription = this.http.get(...).subscribe(...);