Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Function in ng-change is fired before input is touched. #9867

Closed
JonasJonny opened this issue Nov 1, 2014 · 8 comments
Closed

Function in ng-change is fired before input is touched. #9867

JonasJonny opened this issue Nov 1, 2014 · 8 comments

Comments

@JonasJonny
Copy link

Today I wanted to "upgrade" to 1.3.1.
Every piece of my app is working but ng-change not anymore.
My function "showPriority()" is called when template is rendering as many times as is items in an object speakers (deferred ajax result from laravel api).
It was working fine (function is called only when I will change the value of input) in 1.3.0-beta.19, but not in 1.3.0-rc.0+ (for 4 items is called 4x, when i will change the value +1x...).

Is there any difference in ngChange?

<div data-ng-repeat="item in speakers | orderBy:sortBy:reverse">
  <input type="text" data-ng-model="item.priority" data-ng-change="showPriority()">
</div>
@caitp
Copy link
Contributor

caitp commented Nov 1, 2014

Hi! It's halloween, terrible time to be filing bugs! (kidding, kidding). Could you post a quick reproduction of this on https://plunkr.co? That would be super helpful.

@JonasJonny
Copy link
Author

Hello Caitlin,
I debugged my code and I found out where is the problem.
It's input attribute maxlength. With maxlength="1" is function change() fired without touch.

Here is plunker http://plnkr.co/n1Iq5uhYog23022Cfvxc

@Narretz
Copy link
Contributor

Narretz commented Nov 1, 2014

Might be related to #9063

@caitp
Copy link
Contributor

caitp commented Nov 4, 2014

It seems to be related to the input value not being a string, actually --- I can't reproduce if the value is a string to begin with. So what we're doing is, we're converting to a string to validate maxlength, and the model value is changing too because of this.

I'll see if I can make a patch for it

@ghost
Copy link

ghost commented Nov 5, 2014

Is this perhaps related to my issue #9918

@frfancha
Copy link

frfancha commented Nov 7, 2014

This is a terrible issue for us because every number is changed in string before we have set the parser.
We have to stay in 1.2 until it is fixed.

@caitp caitp modified the milestones: 1.3.2, 1.3.3 Nov 7, 2014
@petebacondarwin petebacondarwin assigned Narretz and unassigned caitp Nov 10, 2014
@ghost
Copy link

ghost commented Nov 17, 2014

@petebacondarwin petebacondarwin modified the milestones: 1.3.3, 1.3.4 Nov 17, 2014
@Narretz
Copy link
Contributor

Narretz commented Nov 23, 2014

This is going to be fixed in 1.3.4, see e3764e3

@Narretz Narretz closed this as completed Nov 23, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants