Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 66x 66x 38x 77x 9x 68x 68x | import { FormGroup } from '@angular/forms'; /** * Marks all fields in a form group as dirty recursively (i.e. for nested form groups also) * * @param formGroup The form group */ export function markAsDirtyRecursive(formGroup: FormGroup) { Object.keys(formGroup.controls).forEach(key => { if (formGroup.controls[key] instanceof FormGroup) { markAsDirtyRecursive(formGroup.controls[key] as FormGroup); } else { formGroup.controls[key].markAsDirty(); formGroup.controls[key].updateValueAndValidity(); } }); } |