Angular. Error Cannot read properties of null (reading 'addFormGroup')
Solution 1:
Thanks to Jai Saravanan!
In my case I've fixed it this way:
parent html (referring child):
<form [formGroup]="Nsfg.invoiceFormGroup">
<div formGroupName="namespace">
<fileHeaderComponent formGroupName="FileHeader"></fileHeaderComponent>
html child:
<div [formGroup]="fileHeaderFormGroup">
ts child:
export class FileHeaderComponent implements OnInit {
@Input() formGroupName: string;
ngOnInit(): void {
this.fileHeaderFormGroup = NsGet.fileHeader as FormGroup;
}
NsGet is equal to
Nsfg.invoiceFormGroup.get('namespace').get('FileHeader');