angular material2 change button color when clicked

后端 未结 1 1886
感情败类
感情败类 2021-01-23 10:27

I want to change a material mat-mini-fab button\'s color the when button is clicked.

My attempt is like below. But doesn\'t work.

相关标签:
1条回答
  • 2021-01-23 10:51

    You can use [ngClass] to dynamically toggle a css class on click

    <button [ngClass]="{'test': newColor}" (click)="toggleColor()" mat-fab>Primary</button>

    Demo

    0 讨论(0)
提交回复
热议问题