(change) vs (ngModelChange) in angular


Angular 1 does not accept onchange() event, it’s only accepts ng-change() event.

Angular 2, on the other hand, accepts both (change) and (ngModelChange) events, which both seems to be doing the same thing.

What’s the difference?

which one is best for performance?


<input type="text" pInputText class="ui-widget ui-text"
    (ngModelChange)="clearFilter()" placeholder="Find"/>

vs change:

<input type="text" pInputText class="ui-widget ui-text" 
    (change)="clearFilter()" placeholder="Find"/>


(change) event bound to classical input change event.


You can use (change) event even if you don’t have a model at your input as

<input (change)="somethingChanged()">

(ngModelChange) is the @Output of ngModel directive. It fires when the model changes. You cannot use this event without ngModel directive.


As you discover more in the source code, (ngModelChange) emits the new value.


So it means you have ability of such usage:

<input (ngModelChange)="modelChanged($event)">
modelChanged(newObj) {
    // do something with new value

Basically, it seems like there is no big difference between two, but ngModel events gains the power when you use [ngValue].

  <select [(ngModel)]="data" (ngModelChange)="dataChanged($event)" name="data">
      <option *ngFor="let currentData of allData" [ngValue]="currentData">
dataChanged(newObj) {
    // here comes the object as parameter

assume you try the same thing without “ngModel things”

<select (change)="changed($event)">
    <option *ngFor="let currentData of allData" [value]="currentData.id">
    // event comes as parameter, you'll have to find selectedData manually
    // by using e.target.data

Answered By – omeralper

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published