Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng-change get called without even change. #34

Open
hassandad opened this issue Aug 19, 2016 · 14 comments
Open

ng-change get called without even change. #34

hassandad opened this issue Aug 19, 2016 · 14 comments

Comments

@hassandad
Copy link

With default html input checkbox if there is ngChange directive placed, ngChange will not get called untill there is a change. But with your directive, it gets called automatically with the page loads for the first time without user interaction. This seems to me a bug as it is supposed to work exactly like html checkbox. I am having issue with it.

@dallingel
Copy link

I have the same problem. :(

@sebastianha
Copy link
Owner

Hi (sorry for the very late reply),

could you please provide an example for this problem? I tried to proove it with the supplied test application and could not reproduce it.

@hassandad
Copy link
Author

hassandad commented Jan 3, 2017

To reproduce it, just place an ng-change event on your directive and do a alert within ng-change. Then refresh page, when page get load you will see a alert. If it happens, issue is confirmed. ng-change should only called when there is a change. Let me know if you are able to regenerate it after it.

@sebastianha
Copy link
Owner

Here is a simple example with ng-change, which does not trigger it on load: https://jsfiddle.net/83ncr2kr/3/

@michaelcode
Copy link

I have the exact same problem...

@sebastianha
Copy link
Owner

Could you provide an example which shows the problem?

@michaelcode
Copy link

yes: https://jsfiddle.net/544342zL/1/
Run the code and see :)
It's a relation between the repeat and the ng-model.
if you remove the "thevalue" from the ng-model it stops.

@sebastianha
Copy link
Owner

The Problem is, that "a1", "a2", ... are no valid values for the checkbox. See here for a working version: https://jsfiddle.net/da2z3wgb/

@michaelcode
Copy link

i understand what you're saying..
but it's not very functional in specific cases.. in my case i wasn't using those kind of values, i was using 0 and 1 instead of true or false, and works with normal checkboxes.
again, in my case i'm receiving a json generated by ajax/mysql, and mysql doesn't have a proper true or false field type, you must use tinyint which returns 0 and 1 values.
Could you set it to use 0 and 1 to? :)

@sebastianha
Copy link
Owner

See here: https://jsfiddle.net/hppg6sax/

@michaelcode
Copy link

The 0 and 1 values come as numeric, not string...
https://jsfiddle.net/78ynhjbs/

@sebastianha
Copy link
Owner

I will look into it

@michaelcode
Copy link

thx :)

@ghost
Copy link

ghost commented Sep 18, 2018

Hi All, anyone come up with a solution to this? The issue is because of invalid values into the model tied to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants