Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make mat-icon disabled in angular?

Here i have multiple mat-icons, delete named mat-icon i want to make disabled i use disabled properties on this but it gives error like(Can't bind to 'disabled' since it isn't a known property of 'mat-icon') so how to show particular mat-icon disabled in angular 6?

<mat-icon color="warn" style="cursor: pointer;" [disabled]="payloadArray.enabled != 'true' ">delete</mat-icon>
<mat-icon color="warn" style="cursor: pointer;">person_add</mat-icon>
like image 385
Dharmesh Avatar asked Sep 26 '18 10:09

Dharmesh


2 Answers

Use mat-icon inside button tag and then you can use disabled

Try this,

<button mat-icon-button [disabled]="payloadArray.enabled != 'true' " color="primary" >
   <mat-icon color="warn" style="cursor: pointer;" >delete</mat-icon>
</button>
like image 185
Aniket Avhad Avatar answered Oct 05 '22 20:10

Aniket Avhad


Use ngClass directive to add disable

<mat-icon color="warn" [ngClass]="{'disable':payloadArray.enabled !== true}"(click)="onClick()">delete</mat-icon>

Example:https://stackblitz.com/edit/angular-4jdvc9

like image 30
Chellappan வ Avatar answered Oct 05 '22 21:10

Chellappan வ