Here is a template example:
<input type="number" class="form-control" [(ngModel)]="overRideRate" formControlName="OverRideRate">
<input type="number" class="form-control" [ngModel]="overRideRate" formControlName="OverRideRate">
[(ngModel)]="overRideRate"
is the short form of
[ngModel]="overRideRate" (ngModelChange)="overRideRate = $event"
[ngModel]="overRideRate"
is to bindoverRideRate
to theinput.value
(ngModelChange)="overRideRate = $event"
is to updateoverRideRate
with the value ofinput.value
when thechange
event was emitted.
Together they are what Angular2 provides for two-way binding.
Another explanation
[ngModel]="currentHero.name"
is the syntax for one-way binding, while,
[(ngModel)]="currentHero.name"
is for two-way binding, and the syntax is compound from:
[ngModel]="currentHero.name"
and (ngModelChange)="currentHero.name = $event"
If you only need to pass model, use the first one. If your model needs to listen change events (e.g. when input field value changes), use the second one.