javascript - Checkbox ng-click fired twice -


i trying fill checkboxes dynamically , use selected items filter data.

my html

<div class="form-group" ng-repeat="category in categories">   <label class="checkbox" >     <input type="checkbox" ng-model="selection.ids[category.code]" id="{{category.code}}"             ng-click="toggleselection(category)"            />     {{category.description}}   </label> </div> <div class="form-group">   <button type="submit" ng-click="filtersubmit();" class="btn btn-default">     <span class="glyphicon glyphicon-search"></span> filter   </button> </div> 

in controller using javascript, not unlike other examples i've seen.

$scope.toggleselection = function (category) {   var idx = $scope.selection.indexof(category);   console.log('start '+ idx);    // selected   if (idx > -1) {     $scope.selection.splice(idx, 1);   }   // newly selected   else {     $scope.selection.push(category);   } }; 

sadly enough see console logged twice, once -1, once 0. end no selected checkbox.

when build app using grunt , place on webserver works correctly, when run using grunt serve keeps calling controller twice.

thanks brian, indeed grunt set differently @ different environments. problem solved.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -