I'm trying to use dynamic component loading with formControl but it's not affecting my host formGroup.
Tried those options:
Template:
option 1 - not working:
<div [formGroup]="form">
<ng-container *ngComponentOutlet="getComponent()" [formControlName]="getFormControlName()"></ng-container>
</div>
option 2 - not working:
<div [formGroup]="form">
<ng-container *ngComponentOutlet="getComponent()" [formControl]="getFormControl()"></ng-container>
</div>
option 3 - working:
<div [formGroup]="form">
<my-dynamic-component [formControl]="dynamicFormControl"></my-dynamic-component>
</div>
Component functions:
getComponent: return dynamic component (that supports the use of reactiveForm)
getFormControlName: return formControl name. return string
getFormControl: return formControl object. FormControl
Someone knows what i should do? this is possible?
Check out that example: https://stackblitz.com/edit/angular-n8sdrm?embed=1&file=app/app.component.html
Thanks