Hope this can lead some people to a better understanding of Angular2 forms. Angular has two different approaches to building forms (Reactive and Template form). Without knowing this, you may encounter confusing applications.
valuesChages is a property of the NgModel directive, and the FormControl class (remember this).
Reactive approaches use ReactiveFormsModule import (Your.module.ts):
import {ReactiveFormsModule} from '@angular/forms'; @NgModule({ ... imports: [ ... ReactiveFormsModule, ... ], ... })
This way you can use the [(formControl)] property for your form controls (template.component.html).
<input type="text" class="form-control" id="searchBox" required [(formControl)]="searchBox"/>
Template Approach (your .module.ts):
import {FormsModule} from '@angular/forms'; @NgModule({ ... imports: [ ... FormsModule, ... ], ... })
This object has its own form control properties, ngModel (your.template.ts):
<input type="text" class="form-control" id="searchBox" required [(ngModel)]="searchBox"/>
source share