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

Method constructor

packages/forms/src/model/form_control.ts:469–497  ·  view source on GitHub ↗
(
    // formState and defaultValue will only be null if T is nullable
    formState: FormControlState<TValue> | TValue = null as unknown as TValue,
    validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null,
    asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null,
  )

Source from the content-addressed store, hash-verified

467 _pendingChange: boolean = false;
468
469 constructor(
470 // formState and defaultValue will only be null if T is nullable
471 formState: FormControlState<TValue> | TValue = null as unknown as TValue,
472 validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null,
473 asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null,
474 ) {
475 super(pickValidators(validatorOrOpts), pickAsyncValidators(asyncValidator, validatorOrOpts));
476 this._applyFormState(formState);
477 this._setUpdateStrategy(validatorOrOpts);
478 this._initObservables();
479 this.updateValueAndValidity({
480 onlySelf: true,
481 // If `asyncValidator` is present, it will trigger control status change from `PENDING` to
482 // `VALID` or `INVALID`.
483 // The status should be broadcasted via the `statusChanges` observable, so we set
484 // `emitEvent` to `true` to allow that during the control creation process.
485 emitEvent: !!this.asyncValidator,
486 });
487 if (
488 isOptionsObj(validatorOrOpts) &&
489 (validatorOrOpts.nonNullable || validatorOrOpts.initialValueIsDefault)
490 ) {
491 if (isFormControlState(formState)) {
492 this.defaultValue = formState.value;
493 } else {
494 this.defaultValue = formState;
495 }
496 }
497 }
498
499 override setValue(
500 value: TValue,

Callers

nothing calls this directly

Calls 7

_applyFormStateMethod · 0.95
pickValidatorsFunction · 0.90
pickAsyncValidatorsFunction · 0.90
isOptionsObjFunction · 0.90
isFormControlStateFunction · 0.70
_setUpdateStrategyMethod · 0.45

Tested by

no test coverage detected