Answers for "angular formgroup mark as touched"

1

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);
    }
  });
}
Posted by: Guest on May-21-2020

Code answers related to "angular formgroup mark as touched"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language