0

I have a list of check boxes...

<div class="checkBoxGroup" ng-repeat="service in getAdditionalServices()">
                <input ng-click="additionalServiceClick($index)" type="checkbox" value="{{service.text}}"><span class="fieldTitle">{{service.text}}</span>
</div>

Event handler...

$scope.additionalServiceClick = function ($index) {


};

In the 'additionalServiceClick' function I want to update an array of checked services. But angular unselects any attempt to check a check box if an ng-click handler is assigned.

How to get Angular to bog off in this instance?

Ian Warburton
  • 15,170
  • 23
  • 107
  • 189
  • 1
    I've had instances where a click event triggered the view to refresh, but the model was never updated with the new values, so it appeared that it was unchecking by boxes. I can't remember the solution, but it's something you can look into. – Walter Stabosz Jul 21 '13 at 13:29
  • Yes I was just thinking that was the problem. I've hard coded the list of check boxes for now. – Ian Warburton Jul 21 '13 at 13:33
  • This guy's got the right idea.. http://stackoverflow.com/a/14520103/221683 – Ian Warburton Jul 21 '13 at 13:58
  • When returning my services for binding I've wrapped them in another object that contains an additional property of whether the item has been selected which is derived from looking for the item in the array of selected services. – Ian Warburton Jul 21 '13 at 13:59
  • Horribly slow though. – Ian Warburton Jul 21 '13 at 14:52

0 Answers0