crea8ive_mind crea8ive_mind - 1 year ago 87
AngularJS Question

Yet another AngularJS Error: ngRepeat:dupes

I am playing around with Angular and I have stumbled on another issue. I am trying to pull data from an external js file and I received the 'Error: ngRepeat:dupes' error.

<div class="productRow" ng-repeat="prod in productsList">

So following the direction provided in the error message, I added 'track by'

<div class="productRow" ng-repeat="prod in productsList track by $index">

My data appeared, but now it is only repeating one item multiple times.

Please check out this link for full code.

Am I doing something wrong? I mean obviously I am, but what I am doing wrong?


Answer Source

Angular is not the issue, it displays the arrays you provided it with.

In script.js if you add console.log($scope.productsList); after it's generated you'll see what I mean.

Your problem is under this line

if (productItems[ii] == products[jj].id)

you are not resetting thisProduct

Add this underneath thisProduct = {};

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download