In my Angular 4 app, I have a form with several controls.
At some points I need to force the update of their validity, so I\'m doing:
this.form.get(\
I solved my issue, which was similar to yours, by recursing the controls and manually triggering the update. Probably this is not an optimal solution:
private triggerValidation(control: AbstractControl) {
if (control instanceof FormGroup) {
const group = (control as FormGroup);
for (const field in group.controls) {
const c = group.controls[field];
this.triggerValidation(c);
}
}
else if (control instanceof FormArray) {
const group = (control as FormArray);
for (const field in group.controls) {
const c = group.controls[field];
this.triggerValidation(c);
}
}
control.updateValueAndValidity({ onlySelf: false });
}