I have a column with buttons in a mat-table. Based on a value, I check if the button should be enabled or disabled and works fine. The problem is that if the user click on a disabled button, it will get an error. How I can disable the click event for a disabled button?
<ng-container matColumnDef="download">
<th mat-header-cell *matHeaderCellDef>download</th>
<td mat-cell *matCellDef="let element">
<mat-button [disabled]="isDisabled(element.status)" (click)="download(element.value)"> download </mat-button>
</td>
</ng-container>
<ng-container matColumnDef="download">
<th mat-header-cell *matHeaderCellDef>download</th>
<td mat-cell *matCellDef="let element">
<mat-button [disabled]="isDisabled(element.status)" (click)="!isDisabled(element.status) && download(element.value)"> download </mat-button>
</td>
</ng-container>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.