[英]Icon inside angular 2 component no longer working
Updated to "ionic-framework": "2.0.0-alpha.53" from a much earlier version. 从更早的版本更新为“ ionic-framework”:“ 2.0.0-alpha.53”。 And added this dependency: "ionicons": "3.0.0-alpha.3".
并添加了此依赖项:“ ionicons”:“ 3.0.0-alpha.3”。
I was using this in my html for an Angular 2 component. 我在Angular 2组件的html中使用了它。 There is no ionic content in this html other than me trying to use the ion icons.
除了我尝试使用离子图标外,此html中没有其他离子内容。
<div class="saveButton icon ion-md-add"
(click)="onSaveSelected()"></div>
This worked in alpha 42. How do i use ionic icons in an angular 2 component? 这在alpha 42中有效。如何在角度2组件中使用离子图标? I have tried the following:
我尝试了以下方法:
<div class="saveButton icon ion-md-add"
(click)="onSaveSelected()">
<ion-icon name="heart"></ion-icon>
</div>
This just shows a blank div. 这只是显示一个空白的div。
Whenever i use this line <ion-icon name="heart"></ion-icon>
inside of a <ion-menu>
it works fine. 每当我在
<ion-menu>
内使用此行<ion-icon name="heart"></ion-icon>
,它都可以正常工作。
Thanks 谢谢
If it is a custom component you need to include IONIC_DIRECTIVES in the component:
如果是自定义组件,则需要在该组件中包括IONIC_DIRECTIVES:
import {Component} from 'angular2/core'; import {IONIC_DIRECTIVES} from 'ionic/ionic'; @Component({ selector: 'my-component' template: `<div class="my-style"> <ion-icon name="heart"></ion-icon> </div>`, directives: [IONIC_DIRECTIVES] }) export class MyCustomComponent {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.