我在使用an图标和angular2时遇到了问题。
<span *ngFor="let theIcon of item.getItem().style.get('icon')">
<ons-icon [icon]="theIcon"></ons-icon> {{theIcon}}
</span>
{{theIcon}确实显示正确的图标文本(md-cutlery),ons-图标则从不显示图标。如果我将文本复制到控件中并将其更改为icon=“md-刀”,它就会显示得很好。
我遗漏了什么?
发布于 2016-08-20 07:26:02
在Angular2中,有不同的指令来创建绑定,还有用于属性、类和样式绑定的指令。由于您想要创建属性绑定,所以需要执行:[attr.icon]="myIconVar"
所以你的代码应该是:
<span *ngFor="let theIcon of item.getItem().style.get('icon')">
<ons-icon [attr.icon]="theIcon"></ons-icon> {{theIcon}}
</span>
https://stackoverflow.com/questions/39054548
复制