如何强制 nz-input-number 改变模型 onkeypress 而不是 onblur?
How to force nz-input-number to change model onkeypress not onblur?
我需要在用户输入 nz-input-number
时更新数据。在正常的 <input>
模型中,默认情况下会以这种方式更改。也许我错过了执行此操作的选项...
我举个例子来说明nz-input-number和raw input的区别。
https://stackblitz.com/edit/angular-mvf5yn
关于 ng-zorro 文档,我认为没有 built-in 选项可以做到这一点:
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)
编辑:
您可以在此输入上添加自己的 EventListener
并触发 blur
或 keydown.enter
,但我认为这将是一种不好的做法。
我使用:
<nz-input-number #myInput (keyup)="myInput.onBlur()"></nz-input-number>
我需要在用户输入 nz-input-number
时更新数据。在正常的 <input>
模型中,默认情况下会以这种方式更改。也许我错过了执行此操作的选项...
我举个例子来说明nz-input-number和raw input的区别。
https://stackblitz.com/edit/angular-mvf5yn
关于 ng-zorro 文档,我认为没有 built-in 选项可以做到这一点:
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)
编辑:
您可以在此输入上添加自己的 EventListener
并触发 blur
或 keydown.enter
,但我认为这将是一种不好的做法。
我使用:
<nz-input-number #myInput (keyup)="myInput.onBlur()"></nz-input-number>