Skip to content

Instantly share code, notes, and snippets.

@girokon
Created February 22, 2017 07:35
Show Gist options
  • Save girokon/3fd12aad4e8f89e9bd5d4096ac7a5481 to your computer and use it in GitHub Desktop.
Save girokon/3fd12aad4e8f89e9bd5d4096ac7a5481 to your computer and use it in GitHub Desktop.
abstrac class Base {
markAllDirty(control: AbstractControl) {
if (control.hasOwnProperty('controls')) {
control.markAsDirty(true); // mark group
let ctrl = <any>control;
for (let inner in ctrl.controls) {
this.markAllDirty(ctrl.controls[inner] as AbstractControl);
}
}
else {
(<FormControl>(control)).markAsDirty(true);
}
}
markAllPrestineAndUntouched(control: AbstractControl) {
if (control.hasOwnProperty('controls')) {
control.markAsPristine(true); // mark group
control.markAsUntouched(true); // mark group
let ctrl = <any>control;
for (let inner in ctrl.controls) {
this.markAllPrestineAndUntouched(ctrl.controls[inner] as AbstractControl);
}
}
else {
(<FormControl>(control)).markAsPristine(true);
(<FormControl>(control)).markAsUntouched(true);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment