# Class ControlValueAccessor<T>`Abstract`

#### Type Parameters

- T = any

#### Implements

- ControlValueAccessor

- Defined in packages/angular/forms/src/lib/control-value-accessor.ts:3

#####
Index

### Constructors

constructor

### Methods

onChange?
onTouched?
registerOnChange
registerOnTouched
setDisabledState?
writeValue

##
Constructors

### constructor

- new ControlValueAccessor<T = any>(): ControlValueAccessor<T>

  #### Type Parameters

  - T = any

  #### Returns ControlValueAccessor<T>

##
Methods

### `Optional` onChange

- onChange(value: null | T): void

  #### Parameters

  - value: null | T

  #### Returns void

  - Defined in packages/angular/forms/src/lib/control-value-accessor.ts:7

### `Optional` onTouched

- onTouched(): void

  #### Returns void

  - Defined in packages/angular/forms/src/lib/control-value-accessor.ts:11

### registerOnChange

- registerOnChange(fn: (value: null | T) => void): void

  #### Parameters

  - fn: (value: null | T) => void

    The callback function to register

  #### Returns void

  #### Description

  Registers a callback function that is called when the control's value changes in the UI.

  This method is called by the forms API on initialization to update the form model when values propagate from the view to the model.

  When implementing the `registerOnChange` method in your own value accessor, save the given function so your class calls it at the appropriate time.

  #### Usage Notes

  ### Store the change function

  The following example stores the provided function as an internal method.

      registerOnChange(fn: (_: any) => void): void {
        this._onChange = fn;
      }

  When the value changes in the UI, call the registered function to allow the forms API to update itself:

      host: {
         '(change)': '_onChange($event.target.value)'
      }

  Implementation of NgControlValueAccessor.registerOnChange

  - Defined in packages/angular/forms/src/lib/control-value-accessor.ts:14

### registerOnTouched

- registerOnTouched(fn: () => void): void

  #### Parameters

  - fn: () => void

    The callback function to register

  #### Returns void

  #### Description

  Registers a callback function that is called by the forms API on initialization to update the form model on blur.

  When implementing `registerOnTouched` in your own value accessor, save the given function so your class calls it when the control should be considered blurred or "touched".

  #### Usage Notes

  ### Store the callback function

  The following example stores the provided function as an internal method.

      registerOnTouched(fn: any): void {
        this._onTouched = fn;
      }

  On blur (or equivalent), your class should call the registered function to allow the forms API to update itself:

      host: {
         '(blur)': '_onTouched()'
      }

  Implementation of NgControlValueAccessor.registerOnTouched

  - Defined in packages/angular/forms/src/lib/control-value-accessor.ts:18

### `Optional` setDisabledState

- setDisabledState(isDisabled: boolean): void

  #### Parameters

  - isDisabled: boolean

  #### Returns void

  Implementation of NgControlValueAccessor.setDisabledState

  - Defined in packages/angular/forms/src/lib/control-value-accessor.ts:23

### `Abstract` writeValue

- writeValue(value: T): void

  #### Parameters

  - value: T

  #### Returns void

  #### Description

  Writes a new value to the element.

  This method is called by the forms API to write to the view when programmatic changes from model to view are requested.

  #### Usage Notes

  ### Write a value to the element

  The following example writes a value to the native DOM element.

      writeValue(value: any): void {
        this._renderer.setProperty(this._elementRef.nativeElement, 'value', value);
      }

  Implementation of NgControlValueAccessor.writeValue

  - Defined in packages/angular/forms/src/lib/control-value-accessor.ts:4