I'm upgrading an application from Angular 2 to 7, and it looks like most of my forms have broken. I have multiple instances where I receive the following error:
Property 'controls' does not exist on type 'AbstractControl'
In this particular instance, I have a block that appears to looping through and validating form arrays.
for (let i = 0, len = this.form.controls[control].controls.length; i < len; i++) {
this.form.controls[control].controls[i].controls.ConditionTypeId.setValidators(Validators.required);
this.form.controls[control].controls[i].controls.ConditionTypeId.updateValueAndValidity();
this.form.controls[control].controls[i].controls.ToBeCompletedDate.setValidators(Validators.required);
this.form.controls[control].controls[i].controls.ToBeCompletedDate.updateValueAndValidity();
}
Has there been a major change in how nested forms/form arrays work since Angular 2, and if so, what would be the most efficient way for me to refactor any code that deals with nested forms in this manner?