feat(forms): add ability to reset forms (#9974)

Closes #4914
Closes #4933
This commit is contained in:
Kara
2016-07-12 15:02:25 -07:00
committed by GitHub
parent 806a25413c
commit da8eb9f8b8
9 changed files with 705 additions and 23 deletions

View File

@ -49,8 +49,13 @@ export function setUpControl(control: FormControl, dir: NgControl): void {
control.markAsDirty();
});
// model -> view
control.registerOnChange((newValue: any) => dir.valueAccessor.writeValue(newValue));
control.registerOnChange((newValue: any, emitModelEvent: boolean) => {
// control -> view
dir.valueAccessor.writeValue(newValue);
// control -> ngModel
if (emitModelEvent) dir.viewToModelUpdate(newValue);
});
// touched
dir.valueAccessor.registerOnTouched(() => control.markAsTouched());