I have a nested FormGroup as below:
formData = new FormGroup({
item0: this.createForm(),
item1: this.createForm(),
item2: this.createForm(),
item3: this.createForm()
});
each item is a formgroup with 3 properties created by the createForm function:
createForm() {
return new FormGroup({
title: new FormControl(undefined, Validators.required),
imgData: new FormControl(undefined, Validators.required),
description: new FormControl(undefined, Validators.required)
});
}
now I need to access the value inside imgData of, for example, item2, so I tried:
formData.controls['item2'].controls['imgData'].value
but it has an error: Property 'controls ' does not exist on type 'AbstractControl'.
when I try using .get('imgData') it works just fine, though.
Is there a way to achieve this without get and just use with controls?