Angular 2如何从动态同级组件收集数据?

Angular 2如何从动态同级组件收集数据?,angular,Angular,嗨,我的主组件中有2个相同级别的组件,我的一个同级组件有一个表单,我需要从另一个同级组件收集表单数据 <tab [tabTitle]="'Quote'"> <div #quotedetails></div> </tab> @ViewChild('quotedetails', { read: ViewContainerRef }) target: ViewContainerRef; private componentRef: Comp

嗨,我的主组件中有2个相同级别的组件,我的一个同级组件有一个表单,我需要从另一个同级组件收集表单数据

 <tab [tabTitle]="'Quote'"> <div  #quotedetails></div> </tab>
 @ViewChild('quotedetails', { read: ViewContainerRef }) target: ViewContainerRef;
    private componentRef: ComponentRef<any>;

 private children = {
        LHI: LHIComponent,
        Test: TestComponent
    };


ngAfterContentInit() {

        let childComponent = this.children['LHI'];

        let componentFactory = this.compiler.resolveComponentFactory(childComponent);
        this.componentRef = this.target.createComponent(componentFactory);

    }


 constructor(private policyService: PolicyService, private compiler: ComponentFactoryResolver) {


    }
并在我的组件端使用FormBuilder构建控制器

 policyForm: FormGroup;

 constructor(private fb: FormBuilder) {

this.policyForm = this.fb.group({

PostCode : this.fb.control(null),


 }),

}
下面是如何在主组件中渲染动态组件

 <tab [tabTitle]="'Quote'"> <div  #quotedetails></div> </tab>
 @ViewChild('quotedetails', { read: ViewContainerRef }) target: ViewContainerRef;
    private componentRef: ComponentRef<any>;

 private children = {
        LHI: LHIComponent,
        Test: TestComponent
    };


ngAfterContentInit() {

        let childComponent = this.children['LHI'];

        let componentFactory = this.compiler.resolveComponentFactory(childComponent);
        this.componentRef = this.target.createComponent(componentFactory);

    }


 constructor(private policyService: PolicyService, private compiler: ComponentFactoryResolver) {


    }
@ViewChild('quotedetails',{read:ViewContainerRef})目标:ViewContainerRef;
私有componentRef:componentRef;
独生子女={
LHI:LHI组件,
测试:TestComponent
};
ngAfterContentInit(){
让childComponent=this.children['LHI'];
让componentFactory=this.compiler.resolveComponentFactory(childComponent);
this.componentRef=this.target.createComponent(componentFactory);
}
构造函数(私有policyService:policyService,私有编译器:ComponentFactoryResolver){
}
这是兄弟姐妹的观点

<quote-summary  [policyDetail]="policyDetail" [summary]="summary" ></quote-summary> 


因此,我需要在“quote summary”组件中评估表单

请添加显示如何实现表单的部分。@GünterZöchbauer也请提供创建表单的代码。@GünterZöchbauer doneI不知道这里如何涉及
ComponentFactoryResolver
 <tab [tabTitle]="'Quote'"> <div  #quotedetails></div> </tab>
 @ViewChild('quotedetails', { read: ViewContainerRef }) target: ViewContainerRef;
    private componentRef: ComponentRef<any>;

 private children = {
        LHI: LHIComponent,
        Test: TestComponent
    };


ngAfterContentInit() {

        let childComponent = this.children['LHI'];

        let componentFactory = this.compiler.resolveComponentFactory(childComponent);
        this.componentRef = this.target.createComponent(componentFactory);

    }


 constructor(private policyService: PolicyService, private compiler: ComponentFactoryResolver) {


    }