vicenrele
vicenrele

Reputation: 971

Model not change. multiple ng-repeat and checkbox in last of them.

If I have multiple ng-repeat and checkbox in last of them, all checkboxes are checked if I push one of them. How to resolve the problem?

Example:

<div ng-repeat="(ctIndex, ct) in cts">
  <div ng-repeat="cs in ct track by $index">
     <!-- One checkbox: using ng-checked in place of ng-model --> 
     <div ng-repeat="(tId, task) in cs">
        <input type="checkbox" id="taskChecked{{ctIndex}}_{{$index}}_{{tId}}" data-ng-change="checkTask(ctIndex, $index, tId)" name="task{{ctIndex}}_{{$index}}_{{tId}}" data-ng-model="task.selected">
     </div>
  </div>
</div>

Edit: Solved with @ManojLodhi's answer, but now I have another problem. The model doesn't change (true or false) to "task.selected"

Upvotes: 0

Views: 96

Answers (1)

Amit
Amit

Reputation: 46323

All your checkboxes connect to the same property in your model:

data-ng-model="task.selected"

You need independent model properties for independent checkboxes.

Upvotes: 1

Related Questions