GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • Tutorials
  • Playground
  • Reference
  • code
  • ControlValueAccessor
  • FormControlDirective
  • FormControlName
  • NgModel
  • DefaultValueAccessor

This view

  • Original page
  • New address

GeezerVison is showing next.angular.dev — DefaultValueAccessor • Angular

API

    
      class DefaultValueAccessor extends BaseControlValueAccessor implements ControlValueAccessor {}
    
    
@paramrendererRenderer2
@paramelementRefElementRef<any>
@param_compositionModeboolean
@returnsDefaultValueAccessor

Description

The default ControlValueAccessor for writing a value and listening to changes on input elements. The accessor is used by the FormControlDirective, FormControlName, and NgModel directives.

Exported by

  • ReactiveFormsModule
  • FormsModule

Usage Notes

Using the default value accessor

The following example shows how to use an input element that activates the default value accessor (in this case, a text field).

const firstNameControl = new FormControl();
<input type="text" [formControl]="firstNameControl">

This value accessor is used by default for <input type="text"> and <textarea> elements, but you could also use it for custom components that have similar behavior and do not require special processing. In order to attach the default value accessor to a custom element, add the ngDefaultControl attribute as shown below.

<custom-input-component ngDefaultControl [(ngModel)]="value"></custom-input-component>
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.