Question
Angular (change) vs (ngModelChange): What’s the Difference?
Question
In Angular, I noticed that AngularJS commonly used ng-change, while modern Angular supports both (change) and (ngModelChange).
These two bindings can appear similar because both can be used with input fields:
<input
type="text"
pInputText
class="ui-widget ui-text"
(ngModelChange)="clearFilter()"
placeholder="Find"
/>
and:
<input
type="text"
pInputText
class="ui-widget ui-text"
(change)="clearFilter()"
placeholder="Find"
/>
What is the actual difference between (change) and (ngModelChange) in Angular?
When does each event fire, and which one should be preferred for better performance or more appropriate behavior?
Short Answer
By the end of this page, you will understand that (change) and (ngModelChange) are not the same in Angular. You will learn when each event fires, what data each provides, how they relate to forms and ngModel, and which one to choose depending on whether you want updates on every input change or only after the user finishes editing.
Concept
(change) and (ngModelChange) serve different purposes, even though they are often attached to the same form controls.
(change)
(change) listens to the browser's native DOM change event.
For text inputs, this usually fires when:
- the user changes the value
- and then the input loses focus
For some other controls, such as checkboxes or selects, it may fire immediately when the value changes.
This event is part of standard HTML and exists even outside Angular.
Example:
<input (change)="onChange($event)" />
Here, $event is the native DOM event object.
(ngModelChange)
(ngModelChange) is an Angular event emitted by the NgModel directive.
It fires when Angular updates the model value connected to ngModel. For text inputs, this usually happens on each user edit as the value changes.
Mental Model
Think of an input field like a note pad.
(ngModelChange)is like getting notified every time the pencil writes a new letter.(change)is like getting notified when the person puts the pencil down and says, “I’m done editing this for now.”
So:
- use
(ngModelChange)for live updates - use
(change)for final or committed updates
That simple distinction helps you choose the right event quickly.
Syntax and Examples
Basic syntax
Native DOM change event
<input (change)="handleChange($event)" />
- Uses the browser event
$eventis a DOMEvent
Angular model change event
<input [(ngModel)]="search" (ngModelChange)="handleModelChange($event)" />
- Uses Angular's
ngModel $eventis the new input value
Example: see the difference
<input
[(ngModel)]="search"
(ngModelChange)="onModelChange($event)"
(change)="onNativeChange($event)"
/>
search = '';
() {
.(, value);
}
() {
input = event. ;
.(, input.);
}
Step by Step Execution
Consider this example:
<input
[(ngModel)]="username"
(ngModelChange)="onModelChange($event)"
(change)="onChange($event)"
/>
username = '';
onModelChange(value: string) {
console.log('model changed to:', value);
}
onChange(event: Event) {
const input = event.target as HTMLInputElement;
console.log('native change to:', input.value);
}
Step-by-step when the user types a, b, c
Step 1: user types a
- Angular updates the
ngModelvalue
Real World Use Cases
When to use (ngModelChange)
Live search
<input [(ngModel)]="query" (ngModelChange)="filterResults($event)" />
Useful when you want to filter a list as the user types.
Instant validation
<input [(ngModel)]="email" (ngModelChange)="checkEmailFormat($event)" />
Useful for showing validation feedback immediately.
Live preview
<input [(ngModel)]="title" (ngModelChange)="updateSlug($event)" />
Useful when one field updates another in real time.
When to use (change)
Save only after editing finishes
<input [()]= ()= />
Real Codebase Usage
In real Angular codebases, developers choose these events based on intent.
Common patterns with (ngModelChange)
Search with debouncing
Developers often combine (ngModelChange) with RxJS or a debounced method so the app does not call an API on every keystroke.
<input [(ngModel)]="query" (ngModelChange)="onSearchInput($event)" />
Typical use cases:
- search boxes
- autocomplete
- instant calculations
- dynamic filtering
Common patterns with (change)
Commit-style updates
Developers use (change) when they only care about the final changed value.
Typical use cases:
- settings screens
- profile forms
- dropdown selection
- checkbox state changes
Validation and guard clauses
With either event, developers usually avoid doing expensive work unnecessarily.
onModelChange(value: ) {
(!value.()) {
;
}
.(value);
}
Common Mistakes
1. Thinking both events fire at the same time
They usually do not.
(ngModelChange)fires during model updates(change)usually fires after the user finishes editing and the input loses focus
2. Expecting the same $event value
This is one of the most common mistakes.
Broken example
<input [(ngModel)]="name" (change)="logValue($event)" />
logValue(value: string) {
console.log(value.toUpperCase());
}
This is wrong because (change) passes a DOM event, not a string.
Correct version
logValue(event: Event) {
const input = event.target ;
.(input..());
}
Comparisons
| Feature | (change) | (ngModelChange) |
|---|---|---|
| Source | Native DOM event | Angular NgModel event |
Requires ngModel | No | Yes, typically |
| Fires for text input | Usually after value changes and blur happens | Usually on each value update |
$event contains | DOM Event | New model value |
| Good for live typing updates | No | Yes |
| Good for final/committed updates | Yes | Sometimes, but not ideal |
Cheat Sheet
Quick reference
Use (change) when
- you want the native browser
changeevent - you only need the value after editing is finished
- you are working with selects, checkboxes, or final input changes
<input (change)="onChange($event)" />
Use (ngModelChange) when
- you are using
[(ngModel)] - you want updates as the user types
- you need the new value directly
<input [(ngModel)]="value" (ngModelChange)="onValueChange($event)" />
Event payloads
(change)
onChange(event: Event) {
const input = event.target as ;
.(input.);
}
FAQ
Does (change) fire on every keystroke in Angular?
No. For text inputs, it usually fires only after the value changes and the input loses focus.
Does (ngModelChange) require ngModel?
Yes, it is tied to Angular's NgModel directive and is mainly used with [(ngModel)] or [ngModel].
Which is better for performance: (change) or (ngModelChange)?
(change) usually fires fewer times, so it often does less work. But use the event that matches the behavior you need.
Why does (ngModelChange) give me a value, but (change) gives me an event?
Because (ngModelChange) is an Angular model event that emits the updated value, while (change) is a native DOM event.
Should I use (ngModelChange) for API search?
You can, but usually with debouncing. Otherwise, it may trigger too many requests while the user types.
Can I use both on the same input?
Mini Project
Description
Build a small Angular search box that demonstrates the difference between live updates and final committed updates. The project lets the user type into one input and shows how (ngModelChange) updates results immediately while (change) logs only when editing is finished. This is useful because many real applications need to decide between live filtering and delayed actions.
Goal
Create a component that filters a list as the user types using (ngModelChange) and also tracks when the input value is finally committed using (change).
Requirements
- Create an input bound to a component property with
[(ngModel)]. - Filter a list of items live using
(ngModelChange). - Record the final committed value using
(change). - Display both the live filtered results and the last committed value.
Keep learning
Related questions
@Directive vs @Component in Angular: Differences, Use Cases, and When to Use Each
Learn the difference between @Directive and @Component in Angular, including use cases, examples, and when to choose each.
Angular formControl Error with Material Autocomplete: Why It Happens and How to Fix It
Learn why Angular says it cannot bind to formControl and how to fix Reactive Forms setup with Angular Material Autocomplete.
Angular formGroup Error Explained: Fixing 'Can't bind to formGroup' in Reactive Forms
Learn why Angular shows 'Can't bind to formGroup' and how to fix it by importing ReactiveFormsModule correctly.