Ionic2 + angular2 - disable the button when pressed

I have a list of lines, and each line has 2 more buttons. I want to disable the button in the click event, so as soon as this is done, make an ajax call, then I can turn it on or off again.

So I'm wondering how I can disable this single button on a click event.

how to disconnect an event?

<button [disabled]="buttonDisabled" (click)="trigger($event)"> trigger ($event) { $event.buttonDisabled = true; // ? } 
+5
source share
1 answer
 <div *ngfor="#row of rows"> <button [disabled]="awaitingAjaxCall[row] ? true : null" (click)="trigger($event, row)"> </div> 
 rows: [0,1,2]; awaitingAjaxCall:boolean[] = [false, false, false]; trigger ($event, row) { this.awaitingAjaxCall[row] = true; this.http.get(...).map(...).subscribe(value => { this.value = value; // or here // this.awaitingAjaxCall[row] = false; }, error => {}, () => this.awaitingAjaxCall[row] = false); } 
+4
source

Source: https://habr.com/ru/post/1244309/


All Articles