mrquad mrquad - 1 year ago 52
AngularJS Question

AngularJS - Duplicate Key in ngrepeat error

I want to parse this controller in my view:

testapp.controller("searchController", function($scope, $rootScope, $http, $location) {

var load = function() {
console.log('call load()...');

var url = 'products.json';

if($rootScope && $rootScope.appUrl) {
url = $rootScope.appUrl + '/' + url;

.success(function(data, status, headers, config) {
$scope.product = data;
angular.copy($scope.product, $scope.copy);



However I have implemented the parsing like that:

<div class="container main-frame" ng-app="testapp"
ng-controller="searchController" ng-init="init()">
<h1 class="page-header">Products</h1>
<table class="table">
<th width="25px">ID</th>
<th width="50px"></th>
<tr ng-repeat="p in product">
<!-- ng-show=" &&" -->
<!-- ng-show="user.username" -->

What I am currently getting is:

Error: [ngRepeat:dupes]
at Error (native)
at Object.fn (
at h.$digest (
at h.$apply (
at f (
at E (
at XMLHttpRequest.v.onreadystatechange (

I tried to change it to:

p in product by $id

which gives me a
syntax error

I appreciate your suggestions!

Answer Source

try this

<tr ng-repeat="p in product track by $index">

Usage of track by

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