I have a component that takes FormGroup as @Input.
parentComponent:
parentGroup = fb.group({
childGroup: fb.group({
nestedControl: fb.control([])
})
})
<app-my-component [formGroup]="myGroup">
Then in the child component I have:
@Input formGroup: FormGroup
<div *ngIf="formGroup.controls.childGroup.controls.nestedControl === true">
some content
</div>
I get an error
error TS2339: Property 'controls' does not exist on type 'AbstractControl'.
I guess the child control does not know the structure of formGroup input. How do I typecast AbstractControl to FormGroup within the template? I guess I can make a function that casts in the .ts file and returns formGroup, but that seems cumbersome. Any way to do it in the template? any other clever solutions? :)