如何使用 angular2/4 材质更改单击事件上的材质图标? [英] How to change material-icon on click event with angular2/4 material?
本文介绍了如何使用 angular2/4 材质更改单击事件上的材质图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 md-tab-group 中有以下图标:
I have the following icon within md-tab-group:
<md-tab-group>
<md-tab *ngFor="let tab of arrayOfTabs">
<ng-template md-tab-label>
<md-icon (click)="changetab()">close</md-icon>
</ng-template>
My Tab Content
</md-tab>
</md-tab-group>
我想让它不是关闭"材质图标,而是将其更改为星形"图标.我如何通过该特定选项卡的图标上的点击事件来实现这一点?
I want to make it so that instead of the "close" material icon, change it to a "star" icon. How can I accomplish that through a click event on the icon for that specific tab?
推荐答案
在组件中:
public icon = 'close';
public changeIcon(newIcon: string ){
this.icon = newIcon ;
}
在 HTML 中
<md-icon (click)="changeIcon('star')>{{icon}}</md-icon>
这篇关于如何使用 angular2/4 材质更改单击事件上的材质图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文