When trying to access a nested formgroup like following
this.parentForm = this.FormBuilder.group({
name: [''],
addressGroup: this.FormBuilder.group({
street: [''],
city: ['']
});
});
When try to access street like this.parentForm.controls.addressGroup.controls.street - it throws error Property 'controls' does not exist on type 'AbstractControl', but it does not throw error when accessed like the following this.parentForm.controls.addressGroup['controls'].street
Can someone explain why and what is the reason, I have searched a lot and not able to find any proper reason
object[key]andobject.keyare supposed to produce the exact same output, so I can't really find any relation to Angular. Maybe it's a typescript issue? While debugging and examining theparentFormobject, can you find your way to the desiredcontrolsproperty? Does it contain the data you expected? - fingeron