Ion-input with type number and events input or change


#1

Let’s suppose we have this ion-input:

<ion-input type="number" [(ngModel)]="quantity" (change)="doSomething(quantity)"></ion-input>

The method doSomething() needs the NEW entered quantity to, obviously, do something :slight_smile:

The problem here is when I use the browser arrows for type number (up and down little arrows for increment and decrement the value), because they do not trigger the (change) event. They do trigger the (input) event, but input event gets the old quantity, not the new one entered.

Is it the expected behaviour or is it a bug?

Thank you


#2

@carlosadrian just observed same behaviour in my app, the value is off by 1 when using the arrow keys.


#3

@carlosadrian i switched to using (blur) event instead of (change). With this i got the actual value.


#4

Yes, @ajohan, you are right, but it that way the event is not fired until the ion-input looses the focus, it is not the expected behaviour too. I think the expected behaviour should be (or at least MY expected behaviour) that the model updated each time I press the arrow, and doSomething() is triggered with the NEW value.

Thank you