ng model on change code example

Example 1: angular model change

<input type="checkbox"  (ngModelChange)="myModel=$event" [ngModel]="mymodel">

Example 2: ng model on change

<select [(ngModel)]="selectedItem" (ngModelChange)="onChange($event)">

Example 3: ng model on change

<select [ngModel]="selectedItem" (ngModelChange)="onChange($event)">

Example 4: ng model on change

<select [(ngModel)]="selectedItem" #item (change)="onChange(item.value)">

Example 5: ng model on change

onChange(newValue) {
    console.log(newValue);
    this.selectedItem = newValue;  // don't forget to update the model here
    // ... do other stuff here ...
}

Tags:

Misc Example