Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable a button once clicked in Angular2

I have a silly problem but i didn't know how to overcome it since i'm using Angular2 (Typescript) stuffs not JavaScript's tools. I have this HTML code

<div  class=" uk-align-center" >
 <a class="md-btn md-btn-success" >Start</a>
<!--<a class="md-btn disabled" *ngIf="">Start</a>-->
</div>

Simply , I want to change the button status to disabled once clicked, I found Javascript ways but none of them worked for me, any Help please ?

like image 838
SeleM Avatar asked Jun 18 '16 15:06

SeleM


1 Answers

You can use following approach without touching your component,

<a class="md-btn md-btn-success"
   [class.disabled]="isClickedOnce"
   (click)="isClickedOnce = true">Start</a>
like image 91
codef0rmer Avatar answered Oct 21 '22 06:10

codef0rmer