Angular 如何将对象从父组件传递到使用DCL loadintolocation()创建的子组件?
我正在使用DCL加载一个组件。我想将一个对象传递到该组件中。。我制作了一个plunker演示,其中AppComponent是父对象,这是我想要传递的对象Angular 如何将对象从父组件传递到使用DCL loadintolocation()创建的子组件?,angular,Angular,我正在使用DCL加载一个组件。我想将一个对象传递到该组件中。。我制作了一个plunker演示,其中AppComponent是父对象,这是我想要传递的对象information={name:“Abhi”,place:“Banglore”} export class SomeComponent { public childform: ControlGroup; constructor(fbs: FormBuilder) { this.childform = fbs.group({ 'na
information={name:“Abhi”,place:“Banglore”}代码>
export class SomeComponent {
public childform: ControlGroup;
constructor(fbs: FormBuilder) {
this.childform = fbs.group({
'name': ['', Validators.required],
'place':['']
});
}
}
这是子组件…当加载任何新组件时,我想显示子组件输入框中传递的对象。我不知道如何在DCL中将数据从父级传递到子级…有人请帮助我,伙计们…通过它的实例
getter提供对所创建组件的引用
loadIntoLocation(...).then(ref => {
ref.instance.someField = someValue;
}
当我试图获取ref.instance.items.results的实例时,也可以看到类似的问题,它在我的控制台窗口中显示未定义这是来自FakeComponent
的,对吗@QueryList
仅在ngAfterViewInit()
AFAIK之后填充。您可以将EventEmitter
添加到FakeComponent
,该组件在执行ngAfterViewInit()
时发送事件。然后您可以像ref.instance.afterViewInitCalled.subscribe(值=>{ref.instance.items.result…})一样等待代码>