markAsTouched in angular 8 code example
Example: angular formgroup mark as touched
// From Angular 8/9 you can simply use
this.formGroup.markAllAsTouched();
/**
* For version older than Angular 8
* Marks all controls in a form group as touched
* @param formGroup - The form group to touch
*/
private markFormGroupTouched(formGroup: FormGroup) {
(<any>Object).values(formGroup.controls).forEach(control => {
control.markAsTouched();
if (control.controls) {
this.markFormGroupTouched(control);
}
});
}