Reputation: 270
I have a button with the attribute mat-raised-button
<button mat-raised-button (click)="function()">My Button</button>
I would like to add or remove the mat-raised-button attribute with my function. Is there a way to do this? Or will I need to change the CSS instead?
Upvotes: 1
Views: 6050
Reputation: 58
You can achieve this using only 1 button.
<button class="btn btn-sm" [attr.mat-raised-button]="attributeCondition ? '': null" (click)="changeAttributeCondition()">Button</button>
For ref: Discussion over here
Upvotes: 3
Reputation: 1627
You can use two different buttons and using *ngIf you can display only one at a time based on your condition.
<button mat-button (click)="function()" *ngIf="!isCondition">My Button</button>
<button mat-raised-button (click)="function()" *ngIf="isCondition">My Button</button>
Hope that helps.
Upvotes: 0