MCPcopy Create free account
hub / github.com/angular/angular / setUpDisabledChangeHandler

Function setUpDisabledChangeHandler

packages/forms/src/directives/shared.ts:164–177  ·  view source on GitHub ↗
(control: FormControl, dir: NgControl)

Source from the content-addressed store, hash-verified

162 * @param dir Corresponding directive instance associated with this control.
163 */
164export function setUpDisabledChangeHandler(control: FormControl, dir: NgControl): void {
165 if (dir.valueAccessor!.setDisabledState) {
166 const onDisabledChange = (isDisabled: boolean) => {
167 dir.valueAccessor!.setDisabledState!(isDisabled);
168 };
169 control.registerOnDisabledChange(onDisabledChange);
170
171 // Register a callback function to cleanup disabled change handler
172 // from a control instance when a directive is destroyed.
173 dir._registerOnDestroy(() => {
174 control._unregisterOnDisabledChange(onDisabledChange);
175 });
176 }
177}
178
179/**
180 * Sets up sync and async directive validators on provided form control.

Callers 1

Calls 2

Tested by

no test coverage detected