Skip to content

Commit

Permalink
fix: makes NgModel work in strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Jun 16, 2015
1 parent 5b5ffe7 commit eb3586d
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions modules/angular2/src/forms/directives/ng_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down

0 comments on commit eb3586d

Please sign in to comment.