简体   繁体   中英

ionic2 + angular2 - disable button on click

I have list of rows, and each one row has 2 more more buttons. I want to disable button on click event, so once its done ajax call then I can reenable it or hide it completely.

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

how can I disable from event?

<button [disabled]="buttonDisabled" (click)="trigger($event)">

trigger ($event)
{
  $event.buttonDisabled = true; // ?
}
<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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM