@ -190,6 +190,7 @@ export abstract class AbstractControl {
|
||||
emitEvent = isPresent(emitEvent) ? emitEvent : true;
|
||||
|
||||
this._status = DISABLED;
|
||||
this._errors = null;
|
||||
this._forEachChild((control: AbstractControl) => { control.disable({onlySelf: true}); });
|
||||
this._updateValue();
|
||||
|
||||
@ -232,17 +233,16 @@ export abstract class AbstractControl {
|
||||
onlySelf = normalizeBool(onlySelf);
|
||||
emitEvent = isPresent(emitEvent) ? emitEvent : true;
|
||||
|
||||
this._setInitialStatus();
|
||||
this._updateValue();
|
||||
this._errors = this._runValidator();
|
||||
const originalStatus = this._status;
|
||||
this._status = this._calculateStatus();
|
||||
|
||||
if (this._status == VALID || this._status == PENDING) {
|
||||
this._runAsyncValidator(emitEvent);
|
||||
}
|
||||
if (this.enabled) {
|
||||
this._errors = this._runValidator();
|
||||
this._status = this._calculateStatus();
|
||||
|
||||
if (this._disabledChanged(originalStatus)) {
|
||||
this._updateValue();
|
||||
if (this._status === VALID || this._status === PENDING) {
|
||||
this._runAsyncValidator(emitEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if (emitEvent) {
|
||||
@ -261,6 +261,8 @@ export abstract class AbstractControl {
|
||||
this.updateValueAndValidity({onlySelf: true, emitEvent});
|
||||
}
|
||||
|
||||
private _setInitialStatus() { this._status = this._allControlsDisabled() ? DISABLED : VALID; }
|
||||
|
||||
private _runValidator(): {[key: string]: any} {
|
||||
return isPresent(this.validator) ? this.validator(this) : null;
|
||||
}
|
||||
@ -281,11 +283,6 @@ export abstract class AbstractControl {
|
||||
}
|
||||
}
|
||||
|
||||
private _disabledChanged(originalStatus: string): boolean {
|
||||
return this._status !== originalStatus &&
|
||||
(this._status === DISABLED || originalStatus === DISABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets errors on a form control.
|
||||
*
|
||||
|
Reference in New Issue
Block a user