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

Function setUpControlValueAccessor

packages/forms/src/directives/shared.ts:81–108  ·  view source on GitHub ↗
(
  control: FormControl,
  dir: NgControl,
  callSetDisabledState: SetDisabledStateOption = setDisabledStateDefault,
)

Source from the content-addressed store, hash-verified

79 * @param dir Directive that should be linked with a given control.
80 */
81export function setUpControlValueAccessor(
82 control: FormControl,
83 dir: NgControl,
84 callSetDisabledState: SetDisabledStateOption = setDisabledStateDefault,
85): void {
86 if (typeof ngDevMode === 'undefined' || ngDevMode) {
87 if (!control) _throwError(dir, 'Cannot find control with');
88 if (!dir.valueAccessor) _throwMissingValueAccessorError(dir);
89 }
90
91 setUpValidators(control, dir);
92
93 dir.valueAccessor!.writeValue(control.value);
94
95 // The legacy behavior only calls the CVA's `setDisabledState` if the control is disabled.
96 // If the `callSetDisabledState` option is set to `always`, then this bug is fixed and
97 // the method is always called.
98 if (control.disabled || callSetDisabledState === 'always') {
99 dir.valueAccessor!.setDisabledState?.(control.disabled);
100 }
101
102 setUpViewChangePipeline(control, dir);
103 setUpModelChangePipeline(control, dir);
104
105 setUpBlurPipeline(control, dir);
106
107 setUpDisabledChangeHandler(control, dir);
108}
109
110/**
111 * Reverts configuration performed by the `setUpControl` control function.

Callers 4

_setUpStandaloneMethod · 0.90
_setupWithFormMethod · 0.90
_setupWithFormMethod · 0.90
ngOnChangesMethod · 0.90

Calls 9

_throwErrorFunction · 0.85
setUpValidatorsFunction · 0.85
setUpViewChangePipelineFunction · 0.85
setUpModelChangePipelineFunction · 0.85
setUpBlurPipelineFunction · 0.85
writeValueMethod · 0.65
setDisabledStateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…