Ritu Singh
Problem
I'm facing a strange behavior, I have a simple component that wrap a text input:
Template:
Parent component:
If I modify input and click "cancel", the parent component receives the "change" event, even if the EventEmitter wasn't called. If I change the @Output from "change" to "textChange", this weird behaviour stops. Can you explain me why, and what are the "reserved words" for custom components events?
Steps to reproduce: >https://stackblitz.com/edit/angular-ivy-muspg2?
>file=src%2Fapp%2Fapp.component.ts
change text input
click "cancel"
you can see the received event
Solution
You are facing a native HTML behaviour here. Actually, your HTMLInput element is located in an internal component and emits change events with ability to bubbling. So, to solve this simple problem you have to rename your Output from the change event to any other, or I would prefer to stop bubbling the change event explicitly.
Like this: