单击角度按钮后如何更改按钮的颜色 [英] how to change color of button after clicking button in angular

查看:28
本文介绍了单击角度按钮后如何更改按钮的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在单击按钮后将按钮颜色更改为红色(原色为红色),请帮助我如何在单击按钮后更改颜色.

i need to change button color into red (primary color to red color) after clicking button, please help me how to change color after clicking button.

 <td>
      <button mat-icon-button color="primary">
        <mat-icon>remove_circle</mat-icon>
      </button>
      </td>

推荐答案

在您的代码中实现此逻辑.

Implement this logic in your code.

var isClicked = false;

.myClass{
  color : red;
}

<td>
      <button mat-icon-button color="primary" (click)="isClicked = !isClicked" [class.myClass]="isClicked">
        <mat-icon>remove_circle</mat-icon>
      </button>
      </td>

这篇关于单击角度按钮后如何更改按钮的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆