简体   繁体   English

当我们点击angular中的图标时如何切换多个图标的颜色

[英]How to toggle the color of multiple icons when we click on the icons in angular

I have 8 icons and I have to change the color to black from white when we click on the icon(It has to be toggle).我有 8 个图标,当我们单击图标时,我必须将颜色从白色更改为黑色(它必须是切换的)。

Note: At a time only one icon should be active (change the color).注意:一次只能激活一个图标(更改颜色)。

.component.ts .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

You need to toggle the state of the icon, one way would be like on this example: https://stackblitz.com/edit/angular-font-awesome-starter-5z7mdg?file=src%2Fapp%2Fapp.component.html You need to toggle the state of the icon, one way would be like on this example: https://stackblitz.com/edit/angular-font-awesome-starter-5z7mdg?file=src%2Fapp%2Fapp.component.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM