fix(forms): default the initial value of Control to null
This commit is contained in:
@ -74,7 +74,7 @@ export class NgForm extends ControlContainer implements Form {
|
||||
addControl(dir: NgControl): void {
|
||||
this._later(_ => {
|
||||
var container = this._findContainer(dir.path);
|
||||
var c = new Control("");
|
||||
var c = new Control();
|
||||
setUpControl(c, dir);
|
||||
container.addControl(dir.name, c);
|
||||
c.updateValidity();
|
||||
|
@ -36,7 +36,7 @@ const formControlBinding = CONST_EXPR(new Binding(NgControl, {toAlias: forwardRe
|
||||
exportAs: 'form'
|
||||
})
|
||||
export class NgModel extends NgControl {
|
||||
_control = new Control("");
|
||||
_control = new Control();
|
||||
_added = false;
|
||||
update = new EventEmitter();
|
||||
model: any;
|
||||
|
@ -144,7 +144,7 @@ export class AbstractControl {
|
||||
export class Control extends AbstractControl {
|
||||
_onChange: Function;
|
||||
|
||||
constructor(value: any, validator: Function = Validators.nullValidator) {
|
||||
constructor(value: any = null, validator: Function = Validators.nullValidator) {
|
||||
super(validator);
|
||||
this._value = value;
|
||||
this.updateValidity({onlySelf: true});
|
||||
|
Reference in New Issue
Block a user