1

How to set dynamically list of checkboxes. It seems that what worked in older versions described here doesn't work in angular 1.5.

<div ng-repeat="item in items">
     <input type="checkbox" ng-model="cars[item.id]"  ng-value="{{item.id}}" ng-checked="item.checked == '1'"> {{item.car}}
</div>
$scope.items = [{id:'1', car:'opel', checked:'1'},
               {id:'2', car:'fiat', checked:'1'},
               {id:'3', car:'ford', checked:'0'}];

This loop doesn't work correctly, I didn't get ng-model="cars[1]", ng-model="cars[2]", etc but is ng-model="cars[item.id]"

What I need is dynamically generate list of checkboxes and receive actual state of checked checkboxes:

cars = $scope.cars; //this should return [1, 2]
Community
  • 1
  • 1
Infor Mat
  • 117
  • 3
  • 14

0 Answers0