RSA
RSA

Reputation: 1449

How to disable a button after clicked in ionic2?

In this code i try to disable a button after clicking in Ionic 2

<button ion-button icon-only icon-left (click)="AddMarker()" ng-disabled="clicked" color="light"><ion-icon name="locate" ></ion-icon> </button>

but it is still the same and when clicking the function is calling.

I add this

Upvotes: 1

Views: 10293

Answers (2)

Smit
Smit

Reputation: 2138

var disabled = false;

AddMarker()
{
this.disabled = true;
}
<button ion-button [disabled]="disabled" (click)="disabled=true">
Click me to disable
</button>

<button ion-button [disabled]="disabled" (click)="AddMarker()">
Click me to disable
</button>

Upvotes: 6

Aravind
Aravind

Reputation: 41571

This is how you make the clicked button to disable.

<button ion-button [disabled]="disabled" (click)="disabled=true">
Click me to disable
</button>

If you are using a method in your component use the below code

<button ion-button [disabled]="disabled" (click)="AddMarker()">
Click me to disable
</button>

Method

AddMarker(){
     this.disabled="true";    
}

Upvotes: 1

Related Questions