Disable button after it has been clicked

Hi!

Is there a way to disable a button after it has been clicked?

<button ion-button color="secondary" (click)="trueclick()">Truth</button>

1 Like

Bind the standard HTML disabled attribute to a variable that is set by your handler. This is done on the Angular side of the app vs. the Ionic side of the app

You mean like this?

HTML:

<button ion-button color="secondary" (click)="trueclick()" {{something}}>Truth</button>

TS:

  something;

  trueclick(){
    this.something = 'disabled';
    }

< !-- Bind button disabled state to isUnchanged property -->
< button [disabled]=“isUnchanged”>Save< /button>

See https://angular.io/docs/ts/latest/guide/template-syntax.html for more on this

Chris

2 Likes

hope this help (see disabled attribute)-

<button ion-button color="secondary" (click)="truthClick()" [disabled]="disableButton">Truth</button>

disableButton;

truthClick() {
disableButton = true;
}

3 Likes

It worked! (don’t forget to put this. before disableButton) Thank you very much!