MCPcopy Create free account
hub / github.com/angular/angular / disable

Function disable

packages/forms/src/model/abstract_model.ts:1289–1314  ·  view source on GitHub ↗
(
    opts: {onlySelf?: boolean; emitEvent?: boolean; sourceControl?: AbstractControl} = {},
  )

Source from the content-addressed store, hash-verified

1287 */
1288 disable(opts: {onlySelf?: boolean; emitEvent?: boolean; sourceControl?: AbstractControl}): void;
1289 disable(
1290 opts: {onlySelf?: boolean; emitEvent?: boolean; sourceControl?: AbstractControl} = {},
1291 ): void {
1292 // If parent has been marked artificially dirty we don't want to re-calculate the
1293 // parent's dirtiness based on the children.
1294 const skipPristineCheck = this._parentMarkedDirty(opts.onlySelf);
1295
1296 this.status = DISABLED;
1297 this.errors = null;
1298 this._forEachChild((control: AbstractControl) => {
1299 /** We don't propagate the source control downwards */
1300 control.disable({...opts, onlySelf: true});
1301 });
1302 this._updateValue();
1303
1304 const sourceControl = opts.sourceControl ?? this;
1305 if (opts.emitEvent !== false) {
1306 this._events.next(new ValueChangeEvent(this.value, sourceControl));
1307 this._events.next(new StatusChangeEvent(this.status, sourceControl));
1308 (this.valueChanges as EventEmitter<TValue>).emit(this.value);
1309 (this.statusChanges as EventEmitter<FormControlStatus>).emit(this.status);
1310 }
1311
1312 this._updateAncestors({...opts, skipPristineCheck}, this);
1313 this._onDisabledChange.forEach((changeFn) => changeFn(true));
1314 }
1315
1316 /**
1317 * Enables the control. This means the control is included in validation checks and

Callers

nothing calls this directly

Calls 6

_forEachChildMethod · 0.65
_updateValueMethod · 0.65
emitMethod · 0.65
disableMethod · 0.45
nextMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected