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

Function updateValueAndValidity

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

Source from the content-addressed store, hash-verified

1395 sourceControl?: AbstractControl;
1396 }): void;
1397 updateValueAndValidity(
1398 opts: {onlySelf?: boolean; emitEvent?: boolean; sourceControl?: AbstractControl} = {},
1399 ): void {
1400 this._setInitialStatus();
1401 this._updateValue();
1402
1403 if (this.enabled) {
1404 const shouldHaveEmitted = this._cancelExistingSubscription();
1405
1406 (this as Writable<this>).errors = this._runValidator();
1407 this.status = this._calculateStatus();
1408
1409 if (this.status === VALID || this.status === PENDING) {
1410 // If the canceled subscription should have emitted
1411 // we make sure the async validator emits the status change on completion
1412 this._runAsyncValidator(shouldHaveEmitted, opts.emitEvent);
1413 }
1414 }
1415
1416 const sourceControl = opts.sourceControl ?? this;
1417 if (opts.emitEvent !== false) {
1418 this._events.next(new ValueChangeEvent<TValue>(this.value, sourceControl));
1419 this._events.next(new StatusChangeEvent(this.status, sourceControl));
1420 (this.valueChanges as EventEmitter<TValue>).emit(this.value);
1421 (this.statusChanges as EventEmitter<FormControlStatus>).emit(this.status);
1422 }
1423
1424 if (!opts.onlySelf) {
1425 this._parent?.updateValueAndValidity({...opts, sourceControl});
1426 }
1427 }
1428
1429 /** @internal */
1430 _updateTreeValidity(opts: {emitEvent?: boolean} = {emitEvent: true}): void {

Callers

nothing calls this directly

Calls 4

_updateValueMethod · 0.65
emitMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…