question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

input-number: Should trigger ngModelChange when typing

See original GitHub issue

What problem does this feature solve?

We should always trigger ngModelChange when typing. If developers want to update model value only on blur, they can easily use ngModelOptions to specify its behavior.

我觉得我们应该在用户输入时始终触发 ngModelChange 事件。如果开发者希望在 blur 时才触发更新,可以简单的通过设置 ngModelOptions 指定。

But now we hardcoded its behavior, developers cannot change its behavior back. We use input-number to input integers for most situations, (input) events work fine for those cases.

但是现在在代码中强制了这种行为,用户却无法改回默认的 input 触发。input-number 大多数还是用于输入整数的情况;input 事件对于这种情况工作良好。

Now the behavior is very strange for nonempty validation. The submit button keeps disabled state after user typed some number.

现在做表单的非空验证时行为很奇怪。用户输入了值,提交按钮还是禁用不能点击的状态。

Ref: https://github.com/NG-ZORRO/ng-zorro-antd/issues/2708

What does the proposed API look like?

Trigger ngModelChange event when users’ typing

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
vthinkxiecommented, Feb 11, 2020

Hi all, this issue will be fixed after ng-zorro-antd v9 released

0reactions
joaomvfsantoscommented, Dec 6, 2019

Please consider this. We should not lock out developers to use a functionality because of a possible problem on float since it works correctly on integer. Furthermore, developers could use ngModelOptions to use this behaviour whenever they need to.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 2+ (ngModelChange) on input on itself - Stack Overflow
I have number input field and I want to restrict it so max value will be 100. So When user types ...
Read more >
Difference between (change) and (ngModelChange) in Angular
Using (ngModelChange) essentially is listening to the input event, and setting the model if a user types, pastes or changes the input's value....
Read more >
InputNumber | NG-ZORRO - Ant Design
Angular InputNumber Component, Enter a number within certain range with the mouse or ... (ngModelChange), The callback triggered when the value is changed ......
Read more >
input[number] - AngularJS: API
Text input with number validation and transformation. Sets the number validation error if not a valid number. The model must always be of...
Read more >
ngModelChange and change events in Angular with examples
In Angular, We will use ngModel for two way data binding. Whenever a change happens in ngModel , Angular will trigger ngModelChange event....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found