After adding an array of FormGroups to my form I'm not able to call setValue inside of the FormGroup
This is what I've tried:
this.formGroup.controls.formArray.get('input').setValue('test');
and
this.formGroup.get('formArray').get('input').setValue('test');
Which throws:
Cannot read property 'setValue' of null
TS:
get formArray(): AbstractControl | null { return this.formGroup.get('formArray'); }
this.formGroup = this.fb.group({
formArray: this.fb.array([
this.fb.group({
input: [null, [Validators.required]]
}),
this.fb.group({
anotherInput: [null, [Validators.required]]
}),
])
});
What am I doing wrong?