angular-bootstrap-checkbox icon indicating copy to clipboard operation
angular-bootstrap-checkbox copied to clipboard

ng-change get called without even change.

Open hassandad opened this issue 9 years ago • 14 comments

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.

hassandad avatar Aug 19 '16 12:08 hassandad

I have the same problem. :(

dallingel avatar Nov 25 '16 10:11 dallingel

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.

sebastianha avatar Jan 02 '17 21:01 sebastianha

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.

hassandad avatar Jan 03 '17 05:01 hassandad

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

sebastianha avatar Jan 03 '17 08:01 sebastianha

I have the exact same problem...

michaelcode avatar Apr 03 '17 12:04 michaelcode

Could you provide an example which shows the problem?

sebastianha avatar Apr 03 '17 12:04 sebastianha

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.

michaelcode avatar Apr 03 '17 12:04 michaelcode

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

sebastianha avatar Apr 03 '17 12:04 sebastianha

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? :)

michaelcode avatar Apr 03 '17 13:04 michaelcode

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

sebastianha avatar Apr 03 '17 13:04 sebastianha

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

michaelcode avatar Apr 03 '17 13:04 michaelcode

I will look into it

sebastianha avatar Apr 03 '17 13:04 sebastianha

thx :)

michaelcode avatar Apr 03 '17 14:04 michaelcode

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

ghost avatar Sep 18 '18 22:09 ghost