2015-07-27 22:12:30 -07:00
p.location-badge.
exported from <a href='../forms'>angular2/forms</a>
defined in <a href="https://github.com/angular/angular/tree/2.0.0-alpha.32/modules/angular2/src/forms/directives/ng_model.ts#L13-L75">angular2/src/forms/directives/ng_model.ts (line 13)</a>
:markdown
Binds a domain model to the form.
# Example
```
@Component({selector: "search-comp"})
@View({
directives: [formDirectives],
template: `
<input type='text' [(ng-model)]="searchQuery">
`})
class SearchComp {
searchQuery: string;
}
```
2015-07-28 13:28:47 -07:00
.l-main-section
h2 Annotations
.l-sub-section
h3.annotation Directive
pre.prettyprint
code.
@Directive({
selector: '[ng-model]:not([ng-control]):not([ng-form-control])',
hostInjector: [formControlBinding],
properties: ['model: ngModel'],
events: ['update: ngModel'],
lifecycle: [LifecycleEvent.onChange],
exportAs: 'form'
})
2015-07-27 22:12:30 -07:00
.l-main-section
h2 Members
.l-sub-section
h3 constructor
pre.prettyprint
code.
constructor(ngValidators: QueryList<NgValidator>)
:markdown
.l-sub-section
h3 update
:markdown
.l-sub-section
h3 model
:markdown
.l-sub-section
h3 viewModel
:markdown
.l-sub-section
h3 ngValidators
:markdown
.l-sub-section
h3 onChange
pre.prettyprint
code.
onChange(c: StringMap<string, any>)
:markdown
.l-sub-section
h3 control
:markdown
.l-sub-section
h3 path
:markdown
.l-sub-section
h3 validator
:markdown
.l-sub-section
h3 viewToModelUpdate
pre.prettyprint
code.
viewToModelUpdate(newValue: any)
:markdown