Skip to content Skip to sidebar Skip to footer

Ng-repeat Not Update Model With Track By

I've been using checklist-model to work with an array of check-boxes with each selected one can be deleted. Everything seems to work fine until I use it inside a ng-repeat. The pro

Solution 1:

If you still need to track by, use it with the id of the object. Assuming the id of the object will be always unique.

It is an error to have more than one tracking function to resolve to the same key. (This would mean that two distinct objects are mapped to the same DOM element, which is not possible.)

So instead of this:

<trng-repeat="verb in verbs track by $index"><td><inputtype="checkbox"checklist-model="list.verbs"checklist-value="verb.id"></td><td>
      {{verb.id}}
    </td><td><span>{{verb.text}}</span></td></tr>

use this:

<trng-repeat="verb in verbs track by verb.id"><td><inputtype="checkbox"checklist-model="list.verbs"checklist-value="verb.id"></td><td>
      {{verb.id}}
    </td><td><span>{{verb.text}}</span></td></tr>

http://plnkr.co/edit/UTtQQJIbtRPdGh0YhRMH?p=preview

Post a Comment for "Ng-repeat Not Update Model With Track By"