【发布时间】:2016-12-14 05:03:13
【问题描述】:
我在 Angular2 中有 2 个同级组件:
<test1 *ngIf="data" [data] = "makes" #test1R></formModel>
<testing *ngIf="data" [test1Ref]="test1R"></testing>
组件“Testing”有一个调用test1组件函数的函数:
export class Testing{
@Input() test1Ref: test1Component;
constructor() { }
testFunction($event){
this.test1Ref.hello();
}
我的问题是 this.test1Ref 未定义,因为 test1 组件有 *ngIf (<test1 *ngIf="data") ,
但没有 *ngIf 我在输入值的 test1 组件中有错误 ([data] = "makes")。
如何使用 *ngIf 传递组件引用
【问题讨论】:
标签: angular