Disable button after it has been clicked


#1

Hi!

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

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


#2

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


#3

You mean like this?

HTML:

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

TS:

  something;

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

#4

< !-- 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


#5

hope this help (see disabled attribute)-

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

disableButton;

truthClick() {
disableButton = true;
}


#6

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