Search code examples
angularng-zorro-antd

How to force nz-input-number to change model onkeypress not onblur?


I need to update data while user typing inside nz-input-number. On normal <input> model changes that way by default. Maybe I missed an option to do this... I made an example to illustrate the difference between nz-input-number and raw input. https://stackblitz.com/edit/angular-mvf5yn


Solution

  • I don't think there is a built-in option to do that, regarding to ng-zorro docs:

    Note:InputNumber will validate the input value only when (blur) and (keydown.enter) happened other than when user input character to avoid error ngModelChange output (-0.02001 or -1.0e28)

    EDIT:

    You can add your own EventListener and trigger blur or keydown.enter on this input, but I think it will be a bad practice.