(
opts: {onlySelf?: boolean; emitEvent?: boolean; sourceControl?: AbstractControl} = {},
)
| 1418 | sourceControl?: AbstractControl; |
| 1419 | }): void; |
| 1420 | updateValueAndValidity( |
| 1421 | opts: {onlySelf?: boolean; emitEvent?: boolean; sourceControl?: AbstractControl} = {}, |
| 1422 | ): void { |
| 1423 | this._setInitialStatus(); |
| 1424 | this._updateValue(); |
| 1425 | |
| 1426 | if (this.enabled) { |
| 1427 | const shouldHaveEmitted = this._cancelExistingSubscription(); |
| 1428 | |
| 1429 | this.errors = this._runValidator(); |
| 1430 | this.status = this._calculateStatus(); |
| 1431 | |
| 1432 | if (this.status === VALID || this.status === PENDING) { |
| 1433 | // If the canceled subscription should have emitted |
| 1434 | // we make sure the async validator emits the status change on completion |
| 1435 | this._runAsyncValidator(shouldHaveEmitted, opts.emitEvent); |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | const sourceControl = opts.sourceControl ?? this; |
| 1440 | if (opts.emitEvent !== false) { |
| 1441 | this._events.next(new ValueChangeEvent<TValue>(this.value, sourceControl)); |
| 1442 | this._events.next(new StatusChangeEvent(this.status, sourceControl)); |
| 1443 | (this.valueChanges as EventEmitter<TValue>).emit(this.value); |
| 1444 | (this.statusChanges as EventEmitter<FormControlStatus>).emit(this.status); |
| 1445 | } |
| 1446 | |
| 1447 | if (!opts.onlySelf) { |
| 1448 | this._parent?.updateValueAndValidity({...opts, sourceControl}); |
| 1449 | } |
| 1450 | } |
| 1451 | |
| 1452 | /** @internal */ |
| 1453 | _updateTreeValidity(opts: {emitEvent?: boolean} = {emitEvent: true}): void { |
nothing calls this directly
no test coverage detected