angularjsangularjs-ng-repeatangularjs-ng-model

Using multiple ng-models in a single ng-repeat


I'm trying to get multiple values selected from a checkbox list generated using ng-repeat in Angular

<div ng-repeat="item in items">

<input type="checkbox" ng-model="model.ID" ng-true-value="'{{item.ID}}'" ng-false-value="''"/>{{item.Name}}
</div>

But what I want is to have different ng-models for different checkboxes. How can I do that? Is there a way to do what ng-repeat does without using ng-repeat


Solution

  • In Angular one checkbox is linked with one model, but in practice we usually want one model to store array of checked values from several checkboxes. Checklist-model solves that task without additional code in controller. examples