【问题标题】:How to toggle the color of multiple icons when we click on the icons in angular当我们单击角度中的图标时如何切换多个图标的颜色
【发布时间】:2022-02-03 19:37:23
【问题描述】:

我有 8 个图标,当我们点击图标时,我必须将颜色从白色更改为黑色(它必须是切换的)。

注意:一次只能激活一个图标(更改颜色)。

.component.ts

<div class="container">
  <i class=" icon icon-face-1"></i>
 <i class=" icon icon-face-2"></i>
  <i class=" icon icon-face-3"></i>
  <i class=" icon  icon-face-4"></i>
<i class=" icon  icon-face-5"></i>
<i class=" icon  icon-face-6"></i>
<i class=" icon  icon-face-7"></i>
<i class=" icon  icon-face-8"></i>

</div>

I have tried but not able to do Can anyone help me on this

【问题讨论】:

    标签: javascript html angular ng-class


    【解决方案1】:

    您需要切换图标的状态,一种方式就像在这个例子中: https://stackblitz.com/edit/angular-font-awesome-starter-5z7mdg?file=src%2Fapp%2Fapp.component.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多