fix: makes NgModel work in strict mode

This commit is contained in:
Misko Hevery 2015-06-16 15:53:52 -07:00
parent 5b5ffe75d0
commit eb3586d777
1 changed files with 7 additions and 12 deletions

View File

@ -38,30 +38,25 @@ const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRe
exportAs: 'form'
})
export class NgModel extends NgControl {
control: Control;
ngModel: EventEmitter;
_control = new Control("");
_added = false;
ngModel = new EventEmitter();
model: any;
_added: boolean;
constructor() {
super();
this.control = new Control("");
this.ngModel = new EventEmitter();
this._added = false;
}
onChange(c) {
if (!this._added) {
setUpControl(this.control, this);
setUpControl(this._control, this);
this.control.updateValidity();
this._added = true;
};
if (StringMapWrapper.contains(c, "model")) {
this.control.updateValue(this.model);
this._control.updateValue(this.model);
}
}
get control() { return this._control; }
get path(): List<string> { return []; }
viewToModelUpdate(newValue: any): void { ObservableWrapper.callNext(this.ngModel, newValue); }