我有一个调用组件的页面:
<ion-navbar *navbar class="contact_navbar">
<ion-title>About us</ion-title>
</ion-navbar>
<ion-content>
<ck-about [channel]="ionic" [template]="template_1"></ck-about>
</ion-content>
现在,除了About us
文本,我如何添加可以在ck-about组件中定义并在此处传递的变量?
您可以使用进行设置@ViewChild
,然后使用ngAfterViewInit
可以为“关于我们”设置文本。
@Component({
selector: 'someDir',
templateUrl: 'someTemplate',
directives: [ItemDirective]
})
class SomeDir {
@ViewChild(ItemDirective) viewChild:ItemDirective;
ngAfterViewInit() {
// viewChild is set
}
}
这只是其他方式的一种,但最重要的是,它是首选的方式。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句