ngModelChange called when the input lose focus (type number
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
When using the ngModel
and ngModelChange
in an input with type number
, the function ngModelChange
called when value changes and when the input loses the focus.
Expected behavior
Using the ngModel
and ngModelChange
in an input with type number
behave like a string input type.
Minimal reproduction of the problem with instructions
When using the ngModelChange
with input (default string type ), the ngModelChange
function called one time. But when we change the type to number
, the function called when the input loses the focus also.
Component
/**
* ngModelChange callback
*/
test_event(value) {
console.log(value);
}
html
- Event called one time, even if the input lose the focus
<input [(ngModel)]="test_counter" (ngModelChange)="test_event($event)">
- event called when input lose the focus
<input [(ngModel)]="test_counter" type="number" (ngModelChange)="test_event($event)">
What is the motivation / use case for changing the behavior?
Environment
Angular version: 4.4.6
Browser:
- [x] Chrome (desktop) version 64.0.3282.140
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: v6.11.5
- Platform: Windows
Others:
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (4 by maintainers)
Top Results From Across the Web
input loses focus when editing value. Using ngFor and ...
Though when I start typing in the input field it loses focus and I have to click it again. What am I supposed...
Read more >Binded input loses focus on typing - Google Groups
The problem is that with every change to the model object the ng-repeat regenerates the whole array and so blurs your input box....
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 >Angular ng-blur Directive - W3Schools
Execute an expresson when the input field loses focus (onblur): ... The ng-blur directive tells AngularJS what to do when an HTML element...
Read more >How to fix NgModelChange Previous Value issue in Angular
if you ever have used an input, where on ngModelChange event you have a previous value inside a component, but not the current...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I personally agree this should be improved, please waiting for Angular team to determine.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.