refactor(forms): handle dirty/pristine explicitly

This commit is contained in:
vsavkin
2015-06-03 11:54:39 -07:00
parent 31b6687894
commit 96cadcc29e
3 changed files with 36 additions and 35 deletions

View File

@ -23,13 +23,14 @@ export function setUpControl(c: Control, dir: ControlDirective) {
dir.valueAccessor.registerOnChange(newValue => {
dir.viewToModelUpdate(newValue);
c.updateValue(newValue);
c.markAsDirty();
});
// model -> view
c.registerOnChange(newValue => dir.valueAccessor.writeValue(newValue));
// touched
dir.valueAccessor.registerOnTouched(() => c.touch());
dir.valueAccessor.registerOnTouched(() => c.markAsTouched());
}
function _throwError(dir: ControlDirective, message: string): void {