ngOnChanges not called every time a component property is changed internally. It is called when data binding from the parent component pushes the new value into the child component. Therefore, if your parent component has
<child-comp [name]="parentValue"></child-comp>
When parentValue changes parentValue child component of @Input() name will change and this will call ngOnChanges
Take a look at the docs :
ngOnChanges
Answer when Angular (re) sets the data entry properties ... Called before ngOnInit () and when one or more data entry properties changes.
To receive notifications of changes in your forms, in the end, the best approach is to study Reactive Forms , since they force you to create FormControl objects in your component and set up a very simple observation that is emitted each time the form value changes.
If you want to stick to template-driven forms, you can bind to a keypress or keyup input event to trigger any logic that you want to trigger when changing.
Beetle juice
source share