Created
June 11, 2020 10:54
-
-
Save MarsiBarsi/e204280a9f26781f6e1a310d375e8255 to your computer and use it in GitHub Desktop.
Revisions
-
MarsiBarsi created this gist
Jun 11, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ import {AbstractControl, FormArray, FormGroup} from '@angular/forms'; export function markControlAsTouchedAndValidate(control: AbstractControl) { if (control instanceof FormArray) { control.controls.forEach(nestedControl => { markControlAsTouchedAndValidate(nestedControl); }); return; } if (control instanceof FormGroup) { Object.values(control.controls).forEach(nestedControl => { markControlAsTouchedAndValidate(nestedControl); }); return; } control.markAsTouched(); control.updateValueAndValidity(); }