0Pricing
Angular Academy · Lesson

Writing and Registering Values

Implement writeValue and change callbacks.

Two Core Methods

The heart of a value accessor is moving data both ways: writeValue brings the model value into your view, and the callback from registerOnChange sends user edits back to the model.

writeValue

Angular calls writeValue when the form sets or resets the control's value. Store it in your component state so the view reflects it.

value = 0;

writeValue(value: number): void {
  this.value = value ?? 0;
}

All lessons in this course

  1. The ControlValueAccessor Interface
  2. Writing and Registering Values
  3. Handling Disabled and Touched States
  4. Validation in Custom Controls
← Back to Angular Academy