[@rxap/forms](../wiki/globals) / ControlValueAccessor

# Class: `abstract` ControlValueAccessor\<T\>

Defined in: [packages/angular/forms/src/lib/control-value-accessor.ts:3](https://gitlab.com/rxap/packages/-/blob/3eebed1be2bbb37bc0d65959f8fecbb850c0b8aa/packages/angular/forms/src/lib/control-value-accessor.ts#L3)

## Type Parameters

• **T** = `any`

## Implements

- `ControlValueAccessor`

## Constructors

### new ControlValueAccessor()

> **new ControlValueAccessor**\<`T`\>(): [`ControlValueAccessor`](../wiki/Class.ControlValueAccessor)\<`T`\>

#### Returns

[`ControlValueAccessor`](../wiki/Class.ControlValueAccessor)\<`T`\>

## Methods

### onChange()?

> `optional` **onChange**(`value`): `void`

Defined in: [packages/angular/forms/src/lib/control-value-accessor.ts:7](https://gitlab.com/rxap/packages/-/blob/3eebed1be2bbb37bc0d65959f8fecbb850c0b8aa/packages/angular/forms/src/lib/control-value-accessor.ts#L7)

#### Parameters

##### value

`null` | `T`

#### Returns

`void`

***

### onTouched()?

> `optional` **onTouched**(): `void`

Defined in: [packages/angular/forms/src/lib/control-value-accessor.ts:11](https://gitlab.com/rxap/packages/-/blob/3eebed1be2bbb37bc0d65959f8fecbb850c0b8aa/packages/angular/forms/src/lib/control-value-accessor.ts#L11)

#### Returns

`void`

***

### registerOnChange()

> **registerOnChange**(`fn`): `void`

Defined in: [packages/angular/forms/src/lib/control-value-accessor.ts:14](https://gitlab.com/rxap/packages/-/blob/3eebed1be2bbb37bc0d65959f8fecbb850c0b8aa/packages/angular/forms/src/lib/control-value-accessor.ts#L14)

#### Parameters

##### fn

(`value`) => `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.

```ts
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:

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

#### Implementation of

`NgControlValueAccessor.registerOnChange`

***

### registerOnTouched()

> **registerOnTouched**(`fn`): `void`

Defined in: [packages/angular/forms/src/lib/control-value-accessor.ts:18](https://gitlab.com/rxap/packages/-/blob/3eebed1be2bbb37bc0d65959f8fecbb850c0b8aa/packages/angular/forms/src/lib/control-value-accessor.ts#L18)

#### 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.

```ts
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:

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

#### Implementation of

`NgControlValueAccessor.registerOnTouched`

***

### setDisabledState()?

> `optional` **setDisabledState**(`isDisabled`): `void`

Defined in: [packages/angular/forms/src/lib/control-value-accessor.ts:23](https://gitlab.com/rxap/packages/-/blob/3eebed1be2bbb37bc0d65959f8fecbb850c0b8aa/packages/angular/forms/src/lib/control-value-accessor.ts#L23)

#### Parameters

##### isDisabled

`boolean`

#### Returns

`void`

#### Implementation of

`NgControlValueAccessor.setDisabledState`

***

### writeValue()

> `abstract` **writeValue**(`value`): `void`

Defined in: [packages/angular/forms/src/lib/control-value-accessor.ts:4](https://gitlab.com/rxap/packages/-/blob/3eebed1be2bbb37bc0d65959f8fecbb850c0b8aa/packages/angular/forms/src/lib/control-value-accessor.ts#L4)

#### 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.

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

#### Implementation of

`NgControlValueAccessor.writeValue`
