Created
March 24, 2022 23:32
-
-
Save JeanPaulll/299202b05123c7973f24d93c4370edd8 to your computer and use it in GitHub Desktop.
Function for tapping on angular inputs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static touchInputs(form: FormGroup): void { | |
if (!form) { | |
return; | |
} | |
Object.keys(form.controls).forEach((key) => { | |
if (form.controls[key] instanceof FormGroup) { | |
this.touchInputs(form.controls[key] as FormGroup); | |
} | |
if (form.controls[key] instanceof FormArray) { | |
if (form.controls[key]["controls"].length) { | |
(form.controls[key] as any).controls.forEach((r) => this.touchInputs(r as FormGroup)); | |
} | |
} | |
form.controls[key].markAsTouched(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment