2015-07-27 22:12:30 -07:00
p.location-badge.
exported from <a href='../forms'>angular2/forms</a>
2015-08-06 23:25:42 -07:00
defined in <a href="https://github.com/angular/angular/tree/2.0.0-alpha.34/modules/angular2/src/forms/directives/default_value_accessor.ts#L8-L69">angular2/src/forms/directives/default_value_accessor.ts (line 8)</a>
2015-07-27 22:12:30 -07:00
:markdown
The default accessor for writing a value and listening to changes that is used by the
<a href='NgModel-class.html'><code>NgModel</code></a>, <a href='NgFormControl-class.html'><code>NgFormControl</code></a>, and <a href='NgControlName-class.html'><code>NgControlName</code></a> directives.
# Example
```
<input type="text" [(ng-model)]="searchQuery">
```
2015-07-28 13:28:47 -07:00
.l-main-section
h2 Annotations
.l-sub-section
h3.annotation Directive
pre.prettyprint
code.
@Directive({
selector:
'input:not([type=checkbox])[ng-control],textarea[ng-control],input:not([type=checkbox])[ng-form-control],textarea[ng-form-control],input:not([type=checkbox])[ng-model],textarea[ng-model]',
host: {
'(change)': 'onChange($event.target.value)',
'(input)': 'onChange($event.target.value)',
'(blur)': 'onTouched()',
'[class.ng-untouched]': 'ngClassUntouched',
'[class.ng-touched]': 'ngClassTouched',
'[class.ng-pristine]': 'ngClassPristine',
'[class.ng-dirty]': 'ngClassDirty',
'[class.ng-valid]': 'ngClassValid',
'[class.ng-invalid]': 'ngClassInvalid'
}
})
2015-07-27 22:12:30 -07:00
.l-main-section
h2 Members
.l-sub-section
h3 constructor
pre.prettyprint
code.
constructor(cd: NgControl, renderer: Renderer, elementRef: ElementRef)
:markdown
.l-sub-section
2015-07-28 13:28:47 -07:00
h3 cd
2015-07-27 22:12:30 -07:00
:markdown
.l-sub-section
2015-07-28 13:28:47 -07:00
h3 onChange
2015-07-27 22:12:30 -07:00
:markdown
.l-sub-section
2015-07-28 13:28:47 -07:00
h3 onTouched
2015-07-27 22:12:30 -07:00
:markdown
.l-sub-section
h3 renderer
:markdown
.l-sub-section
h3 elementRef
:markdown
.l-sub-section
h3 writeValue
pre.prettyprint
code.
writeValue(value: any)
:markdown
.l-sub-section
h3 ngClassUntouched
:markdown
.l-sub-section
h3 ngClassTouched
:markdown
.l-sub-section
h3 ngClassPristine
:markdown
.l-sub-section
h3 ngClassDirty
:markdown
.l-sub-section
h3 ngClassValid
:markdown
.l-sub-section
h3 ngClassInvalid
:markdown
.l-sub-section
h3 registerOnChange
pre.prettyprint
code.
2015-07-28 13:28:47 -07:00
registerOnChange(fn: (_: any) => void)
2015-07-27 22:12:30 -07:00
:markdown
.l-sub-section
h3 registerOnTouched
pre.prettyprint
code.
registerOnTouched(fn: () => void)
:markdown