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

Method control

packages/forms/src/form_builder.ts:366–384  ·  view source on GitHub ↗

* @description * Constructs a new `FormControl` with the given state, validators and options. Sets * `{nonNullable: true}` in the options to get a non-nullable control. Otherwise, the * control will be nullable. Accepts a single generic argument, which is the type of the * control's val

(
    formState: T | FormControlState<T>,
    validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null,
    asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null,
  )

Source from the content-addressed store, hash-verified

364 * {@example forms/ts/formBuilder/form_builder_example.ts region='disabled-control'}
365 */
366 control<T>(
367 formState: T | FormControlState<T>,
368 validatorOrOpts?: ValidatorFn | ValidatorFn[] | FormControlOptions | null,
369 asyncValidator?: AsyncValidatorFn | AsyncValidatorFn[] | null,
370 ): FormControl {
371 let newOptions: FormControlOptions = {};
372 if (!this.useNonNullable) {
373 return new FormControl(formState, validatorOrOpts, asyncValidator);
374 }
375 if (isAbstractControlOptions(validatorOrOpts)) {
376 // If the second argument is options, then they are copied.
377 newOptions = validatorOrOpts;
378 } else {
379 // If the other arguments are validators, they are copied into an options object.
380 newOptions.validators = validatorOrOpts;
381 newOptions.asyncValidators = asyncValidator;
382 }
383 return new FormControl<T>(formState, {...newOptions, nonNullable: true});
384 }
385
386 /**
387 * Constructs a new `FormArray` from the given array of configurations,

Callers 15

_createControlMethod · 0.95
reifyControlFunction · 0.45
controlMethod · 0.45
markAsDirtyMethod · 0.45
markAsTouchedMethod · 0.45
markAsPristineMethod · 0.45
markAsUntouchedMethod · 0.45
getControlValueSignalFunction · 0.45
interop.spec.tsFile · 0.45
compat.spec.tsFile · 0.45

Calls 1

isAbstractControlOptionsFunction · 0.85

Tested by

no test coverage detected