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.

ngModelChange called when the input lose focus (type number

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
trotylcommented, Feb 9, 2018

I personally agree this should be improved, please waiting for Angular team to determine.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 13, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

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