How do I avoid double ng-repeat angle keys?

advertisements

Having trouble with duplicate keys in NG-Grid. Search for Tim then click on ng grid column in gridOptions1 to see duplicates in gridOptions2. Any ideas?

Here's plnkr

$scope.gridColumnDefs2 = [
 {displayName:'Phone', cellTemplate:
 '<div data-ng-repeat="(key, ngClickResult) in ngClickResults track by $index">{{ngClickResult.phone}}</div>'},


I like to use track by to solve this, unless there is some reason you should not, try track by $index - that usually does the trick!

<div data-ng-repeat="(key, ngClickResult) in ngClickResults track by $index">

Or if you're actually trying to remove the items from the data you can filter , something like this from this answer here - AngularJs Remove duplicate elements in ng-repeat

Although If you use this second method, unless you are really stuck I would recommend trying to modify the data coming in before it hits the repeat - maybe on the server if you have access to that.