we recently upgraded from ng 7.2.15 and typescript 3.2.4 to angular v8.2.14 and typescript v3.5.3. Passing the form group from a parent component to child component is no longer working.
Below is my child component: child component. ts
@Component({selector:'edit-overview'})
export class ChildComponent implements OnInit {
public OverviewFormGroup : FormGroup
constructor(private controlContainer: ControlContainer) {
}
ngOnInit() {
this.OverviewFormGroup = <FormGroup>this.controlContainer.control;
}
}
child.component.html
<div [formGroup] ='OverviewFormGroup'>
</div>
and my parent component
Parent.component.html
<div [formGroup]="Form1">
<edit-overview [formGroup] = "Form1.controls.OverviewFormGroup">
</edit-overview>
</div>
Parent.component.ts
export class ParentComponent {
constructor(private readonly fb: FormBuilder) {
this.Form1 = this.fb.group({
name: new FormControl('', [Validators.required]),
OverviewFormGroup: new FormGroup({
description: new FormControl('', [Validators.nullValidator])
})
})
}
}
It throws this error: Type 'AbstractControl' is missing the following properties from type 'FormGroup': controls, registerControl, addControl, removeControl, and 3 more at the parent template line.
Earlier passing a formgroup from parent to child was no longer an issue. Am i missing something here? I have already given value for controls in the Form group declaration.