example.html
<input #gb type="text" pInputText class="ui-widget ui-text" [(ngModel)]
="filterText" (ngModelChange)="filterText = $event; clearFilter(filterText)"/>
script.js
clearFilter(value) {
alert(value);// the value is currently empty
}
This alert will trigger every time the input field is focused in or out. I only want the function to execute if there are changes to the model object.
How can this be handled and why does the
ngModelChange
event fire when focusing in and out of the input box?