【发布时间】:2017-06-27 18:26:22
【问题描述】:
我正在使用 Ionic 3.*,试图创建一个仅包含一个按钮的组件。
组件代码为:
@Component({
selector: 'profile-button',
templateUrl: 'profile-button.html',
})
export class ProfileButtonComponent {
constructor(
private popoverCtrl: PopoverController
) {}
/**
* Present the Profile popover
* @param ev
* @returns {Promise<any>}
*/
async presentPopover(ev) {
let popover = this.popoverCtrl.create(ProfilePopover);
return popover.present({
ev
});
}
}
我的模板是:
<button ion-button icon-only (click)="presentPopover($event)" title="Profile">
<ion-icon name="person"></ion-icon>
</button>
问题:
问题是 icon-only 指令被忽略了。该按钮仍然具有背景颜色。
如果我将模板放在组件之外,它会显示正确的样式。
看起来指令在组件中不可用。我的组件在自定义模块中,而不是在 AppModule 中。
我该如何解决这个问题?发现在 Ionic2 上我需要手动导入指令,但在 Ionic3 上不起作用。
【问题讨论】: