MCPcopy Index your code
hub / github.com/angular/angular / disable

Function disable

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

Source from the content-addressed store, hash-verified

1264 */
1265 disable(opts: {onlySelf?: boolean; emitEvent?: boolean; sourceControl?: AbstractControl}): void;
1266 disable(
1267 opts: {onlySelf?: boolean; emitEvent?: boolean; sourceControl?: AbstractControl} = {},
1268 ): void {
1269 // If parent has been marked artificially dirty we don't want to re-calculate the
1270 // parent's dirtiness based on the children.
1271 const skipPristineCheck = this._parentMarkedDirty(opts.onlySelf);
1272
1273 this.status = DISABLED;
1274 (this as Writable<this>).errors = null;
1275 this._forEachChild((control: AbstractControl) => {
1276 /** We don't propagate the source control downwards */
1277 control.disable({...opts, onlySelf: true});
1278 });
1279 this._updateValue();
1280
1281 const sourceControl = opts.sourceControl ?? this;
1282 if (opts.emitEvent !== false) {
1283 this._events.next(new ValueChangeEvent(this.value, sourceControl));
1284 this._events.next(new StatusChangeEvent(this.status, sourceControl));
1285 (this.valueChanges as EventEmitter<TValue>).emit(this.value);
1286 (this.statusChanges as EventEmitter<FormControlStatus>).emit(this.status);
1287 }
1288
1289 this._updateAncestors({...opts, skipPristineCheck}, this);
1290 this._onDisabledChange.forEach((changeFn) => changeFn(true));
1291 }
1292
1293 /**
1294 * 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…