I want to cancel running request by clicking button
When http request call then loader is running but most of the time request taking longer time so that I want to cancel that request while running
here is my html code
<div *ngIf="progress.state | async; let state">
<div class="loading-icon" *ngIf="state.active">
<button class="btn btn--primary" (click)="cancelRequest()">Cancle Request</button>
</div>
</div>
here is my loader.ts file
import { HttpModule, BrowserXhr } from '@angular/http';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NgProgressModule, NgProgressBrowserXhr } from 'ngx-progressbar';
import { SpinnerComponent } from './spinner.component';
@NgModule({
imports: [
CommonModule,
HttpModule,
NgProgressModule
],
declarations: [
SpinnerComponent
],
providers: [
{ provide: BrowserXhr, useClass: NgProgressBrowserXhr },
],
exports:[
SpinnerComponent
]
})
export class PageloaderModule {
cancelRequest(){
}
}
I'm trying to set a Boolean variable in http interceptor but not working
So how can I cancel running http request