I'm using angularjs as much as possible - I'm editing some legacy system and I cannot afford to change too much. So, basically, I need to implement a function that unchecks every checkbox in the page. The easiest solution - without changing too much of the existing system - was to use angular.element. Now I know, this is a REALLY bad solution, but I need to make it work.
Currently, it works (visually at least), since every checkbox gets unchecked, however, on another click the checkbox doesn't work - it needs to be pressed twice, before being activated again.
Here's a demo of how things are and how I've implemented a partial solution: http://jsbin.com/xicubegira/1/edit?html,js,output Use case is as follows.
- Click on checkbox - the counter will increment to 1, checkbox will become checked
- Click on checkbox again - the counter will increment to 2, checkbox will become unchecked
- Click on checkbox - the counter will increment to 3, checkbox will become checked
- Press the 'uncheck me' button - the counter will not increment, checkbox will become unchecked (which is OK)
- Click on checkbox again - the checkbox becomes 'checked', but the counter is not incremented!
So, how could I uncheck all checkboxes in the page and still maintain initial functionality? I'm guessing the issue here is, that nothing changes in scope of checkbox, so ng-change doesn't get fired.
Thanks for your help!