The (change) event in Angular works differently based on how data binding is implemented. Below is a breakdown by version with examples.
In AngularJS, you use ng-model to bind the selected value and ng-change to detect changes.
HTML:
<select ng-model="selectedDevice" ng-change="onChange(selectedDevice)">
<option ng-repeat="device in devices" value="{{device}}">{{ device }}</option>
</select>
JavaScript:
$scope.devices = ['Device 1', 'Device 2', 'Device 3'];
$scope.selectedDevice = '';
$scope.onChange = function(newValue) {
console.log('New Selected Device:', newValue);
};
(ngModelChange) fires immediately when the model updates, making it ideal for real-time updates.
HTML:
<select [(ngmodel)]="selectedDevice" (ngmodelchange)="onChange($event)">
<option *ngfor="let device of devices" [value]="device">{{ device }}</option>
</select>
TypeScript:
onChange(newValue: string) {
console.log('New Selected Device:', newValue);
}
HTML:
<select [(ngmodel)]="selectedDevice" (change)="onChange($event)">
<option *ngfor="let device of devices" [value]="device">{{ device }}</option>
</select>
TypeScript:
onChange(event: Event) {
this.selectedDevice = (event.target as HTMLSelectElement).value;
console.log('New Selected Device:', this.selectedDevice);
}
Angular 17 introduced Signals, an optimized state management approach for better reactivity.
HTML:
<select [value]="selectedDevice()" (change)="onChange($event)">
@for ( device of devices; track device.id) {
<option [value]="device">{{ device.name }}</option>
} @empty {
<li> No devices found </li>
}
</select>
JavaScript:
import { Component, Signal, signal } from '@angular/core';
@Component({
selector: 'app-root',
standalone: true,
templateUrl: './app.component.html',
})
export class AppComponent {
selectedDevice: Signal<string> = signal('');
devices = ['Device 1', 'Device 2', 'Device 3'];
onChange(event: Event) {
this.selectedDevice.set((event.target as HTMLSelectElement).value);
console.log('New Selected Device:', this.selectedDevice());
}
}
</string>
Work with our skilled Angular developers to accelerate your project and boost its performance.
3rd Floor, Aval Complex, University Road, above Balaji Super Market, Panchayat Nagar Chowk, Indira Circle, Rajkot, Gujarat 360005.
Abbotsford, BC
15th B Street 103, al Otaiba Dubai DU 00000, United Arab Emirates
3rd Floor, Aval Complex, University Road, above Balaji Super Market, Panchayat Nagar Chowk, Indira Circle, Rajkot, Gujarat 360005.
Abbotsford, BC
15th B Street 103, al Otaiba Dubai DU 00000, United Arab Emirates
Copyright © 2026 Niotechone Software Solution Pvt. Ltd. All Rights Reserved.