fix(forms): do not reset the value of the input when it came from the view

This commit is contained in:
vsavkin
2015-07-15 18:16:50 -07:00
parent b1df54501a
commit b1231593b6
11 changed files with 81 additions and 34 deletions
+5 -2
View File
@@ -151,10 +151,13 @@ export class Control extends AbstractControl {
this._valueChanges = new EventEmitter();
}
updateValue(value: any, {onlySelf, emitEvent}: {onlySelf?: boolean, emitEvent?: boolean} = {}):
updateValue(value: any,
{onlySelf, emitEvent, emitModelToViewChange}:
{onlySelf?: boolean, emitEvent?: boolean, emitModelToViewChange?: boolean} = {}):
void {
emitModelToViewChange = isPresent(emitModelToViewChange) ? emitModelToViewChange : true;
this._value = value;
if (isPresent(this._onChange)) this._onChange(this._value);
if (isPresent(this._onChange) && emitModelToViewChange) this._onChange(this._value);
this.updateValueAndValidity({onlySelf: onlySelf, emitEvent: emitEvent});
}