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(\
validateFormFields(fields) {
try {
Object.entries(fields.controls).forEach((control: any) => {
if (typeof control[0] == 'Array'
) {
this.validateFormFields(control[1]);
} else {
if (control[1].controls) {
Object.entries(control[1].controls).forEach((c: any) => {
c[1].touched = true;
});
} else {
control[1].touched = true;
}
}
});
} catch (e) {
console.log(e);
}
}