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

Function bindControlProperty

packages/forms/src/directives/ng_control.ts:434–457  ·  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

432 * Binds a status property to FVC, falling back to native DOM if FVC lacks the input.
433 */
434 private bindControlProperty(
435 host: ControlDirectiveHost,
436 bindings: Record<string, unknown>,
437 name: 'disabled' | 'touched' | 'dirty' | 'valid' | 'invalid' | 'pending' | 'required',
438 value: boolean,
439 ): void {
440 if (bindings[name] === value) {
441 return;
442 }
443 bindings[name] = value;
444
445 // Try setting on the custom control first.
446 const wasSet = host.setInputOnDirectives(name, value);
447
448 // Fall back to native DOM property for 'disabled' and 'required'
449 if (
450 this.isNativeFormElement &&
451 !wasSet &&
452 (name === 'disabled' || name === 'required') &&
453 this.renderer
454 ) {
455 setNativeDomProperty(this.renderer, host.nativeElement as NativeFormControl, name, value);
456 }
457 }
458
459 /**
460 * 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