Introduction: Why Does This Topic Blow Up Stack Overflow?
\n\nIf you've ever written in Angular and dealt with handling changes in <input>, you've surely seen two similar events: (change) and (ngModelChange). At first glance — they're the same. In practice — the devil is in the details. The question "(change) vs (ngModelChange) in Angular" gathers thousands of views on Stack Overflow, and for good reason: the wrong choice leads to bugs, unnecessary server requests, and sleepless nights.
In this article on PythonLib, we will figure it out once and for all:
\n- \n
- How are
(change)and(ngModelChange)different in Angular? \n - When to use each one? \n
- How to avoid common pitfalls? \n
Let's go! 🚀
\n\nIn Short: What are (change) and (ngModelChange)?
\n\n(change) is a standard DOM event that fires when an element loses focus (blur) and its value has changed. Angular simply wraps the native change event.
(ngModelChange) is an event of the ngModel directive. It fires every time the model changes — literally with every keystroke (unless ngModelOptions is used).
Important:\n\nngModelChangecannot be used without[(ngModel)]. It is part of two-way binding.
Here is a minimal example in TypeScript to see the difference:
\n\n// app.component.ts\nimport { Component } from '@angular/core';\n\n@Component({\n selector: 'app-root',\n template: `\n <input\n [ngModel]="name"\n (ngModelChange)="onNgModelChange($event)"\n (change)="onChange($event)"\n placeholder="Enter name">\n <p>Value: {{ name }}</p>\n `\n})\nexport class AppComponent {\n name = '';\n\n onNgModelChange(value: string) {\n console.log('ngModelChange:', value);\n }\n\n onChange(event: Event) {\n console.log('change:', (event.target as HTMLInputElement).value);\n }\n}\n\n\nTry typing "Angular" — and you'll see: ngModelChange will fire 7 times (per letter), while change will fire only once, when you click outside the field.
Key Differences: Comparison Table
\n\nFor clarity, here is a table of the key differences (change) vs (ngModelChange):
\n\n| Criterion | \n(change) | \n(ngModelChange) | \n
|---|---|---|
| Event Type | \nNative DOM event | \nAngular event (EventEmitter) | \n
| When it fires | \nOn blur + value change | \nOn every model change (every input) | \n
| Value in $event | \nEvent object (need to extract value) | \nNew model value (string, number, etc.) | \n
| Dependency on ngModel | \nNot required (can be on any input) | \nRequires [(ngModel)] or [ngModel] | \n
| Performance | \nHigh (fires rarely) | \nCan be frequent (on every keypress) | \n
| Usage with forms | \nReactive forms, template-driven | \nTemplate-driven forms only | \n
When to Use (change)?
\n\n(change) is your choice if:
\n- \n
- You need to react only when the field