feat(form): implemented an imperative way of updating the view by updating the value of a control

This commit is contained in:
vsavkin
2015-06-02 16:24:07 -07:00
parent 559f54e92b
commit 652ed0cf6d
9 changed files with 145 additions and 75 deletions
@@ -18,10 +18,15 @@ export function setUpControl(c: Control, dir: ControlDirective) {
c.validator = Validators.compose([c.validator, dir.validator]);
dir.valueAccessor.writeValue(c.value);
// view -> model
dir.valueAccessor.registerOnChange(newValue => {
dir.viewToModelUpdate(newValue);
c.updateValue(newValue);
});
// model -> view
c.registerOnChange(newValue => dir.valueAccessor.writeValue(newValue));
}
function _throwError(dir: ControlDirective, message: string): void {