Is there a way to get the previous(last) value of a field on ngModelChange? What I have goes something like this
HTML
<input type="text" [(ngModel)]="text" (ngModelChange)="textChanged($event)">
Handler
private textChanged(event) {
console.log('changed', this.text, event);
}
What I get is
changed *newvalue* *newvalue*
Of course I can keep the older value using another variable, but is there a better way?
So found kinda weird(at least for me) possible solution for this with least changes in the code in question. So on assigning the (ngModelChange)
attribute before [(ngModel)]
what I get is following with the same handler:
changed *older value* *new value*
I get the new value in this.text
like so:
setTimeout(() => console.log(this.text), 0);