Hi, I have 2 components of the same level in my main component, one of my related components has a form, and I need to collect data from this form from another brother component
<tab [tabTitle]="'Quote'"> <div #quotedetails></div> </tab>
#quotedetails- this download is from a dynamic one ComponentFactoryResolver, this includes a form with data
here is my form
<form [formGroup]="policyForm">
<input type="text" class="form-control" formControlName="PostCode" placeholder="Post Code" />
</form >
and use FormBuilder for the assembly controller on my side of the component
policyForm: FormGroup;
constructor(private fb: FormBuilder) {
this.policyForm = this.fb.group({
PostCode : this.fb.control(null),
}),
}
this is how i render the dynamic component in my main component
@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) {
}
this is kind of sister
<quote-summary [policyDetail]="policyDetail" [summary]="summary" ></quote-summary>
so I need to evaluate the form in the quote-summary component
source
share