MCPcopy
hub / github.com/angular/angular / bindControlProperty

Function bindControlProperty

packages/forms/src/directives/ng_control.ts:307–330  ·  view source on GitHub ↗

* Binds a status property to FVC, falling back to native DOM if FVC lacks the input.

(
    host: ControlDirectiveHost,
    bindings: Record<string, unknown>,
    name: 'disabled' | 'touched' | 'dirty' | 'valid' | 'invalid' | 'pending' | 'required',
    value: boolean,
  )

Source from the content-addressed store, hash-verified

305 * Binds a status property to FVC, falling back to native DOM if FVC lacks the input.
306 */
307 private bindControlProperty(
308 host: ControlDirectiveHost,
309 bindings: Record<string, unknown>,
310 name: 'disabled' | 'touched' | 'dirty' | 'valid' | 'invalid' | 'pending' | 'required',
311 value: boolean,
312 ): void {
313 if (bindings[name] === value) {
314 return;
315 }
316 bindings[name] = value;
317
318 // Try setting on the custom control first.
319 const wasSet = host.setInputOnDirectives(name, value);
320
321 // Fall back to native DOM property for 'disabled' and 'required'
322 if (
323 this.isNativeFormElement &&
324 !wasSet &&
325 (name === 'disabled' || name === 'required') &&
326 this.renderer
327 ) {
328 setNativeDomProperty(this.renderer, host.nativeElement as NativeFormControl, name, value);
329 }
330 }
331
332 /**
333 * Converts Reactive Forms errors to Signal Forms error format.

Callers

nothing calls this directly

Calls 2

setNativeDomPropertyFunction · 0.90
setInputOnDirectivesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…