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

Method _createControl

packages/forms/src/form_builder.ts:422–442  ·  view source on GitHub ↗

@internal

(
    controls: T | FormControlState<T> | ControlConfig<T> | FormControl<T> | AbstractControl<T>,
  )

Source from the content-addressed store, hash-verified

420
421 /** @internal */
422 _createControl<T>(
423 controls: T | FormControlState<T> | ControlConfig<T> | FormControl<T> | AbstractControl<T>,
424 ): FormControl<T> | FormControl<T | null> | AbstractControl<T> {
425 if (controls instanceof FormControl) {
426 return controls as FormControl<T>;
427 } else if (controls instanceof AbstractControl) {
428 // A control; just return it
429 return controls;
430 } else if (Array.isArray(controls)) {
431 // ControlConfig Tuple
432 const value: T | FormControlState<T> = controls[0];
433 const validator: ValidatorFn | ValidatorFn[] | null =
434 controls.length > 1 ? controls[1]! : null;
435 const asyncValidator: AsyncValidatorFn | AsyncValidatorFn[] | null =
436 controls.length > 2 ? controls[2]! : null;
437 return this.control<T>(value, validator, asyncValidator);
438 } else {
439 // T or FormControlState<T>
440 return this.control<T>(controls);
441 }
442 }
443}
444
445/**

Callers 2

arrayMethod · 0.95
_reduceControlsMethod · 0.95

Calls 2

controlMethod · 0.95
isArrayMethod · 0.80

Tested by

no test coverage detected