Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am getting this error:

Duplicates in a repeater are not allowed. Repeater: session in privateKeyList key: string:I

This is my JavaScript code:

  success(function(data, status, headers, config) {
                      $scope.privateKeyList = data.privateKeyList;

                    $scope.totalPrivKey=data.totalPrivateKey;

This is my JSP code:

       <tbody  ng-repeat="session in privateKeyList">
          <tr>
                                <td>{{session.ptID}}</td>
                                <td>{{session.encID}}</td>
                                <td>{{session.doctorID}}</td>

         </tr>

This is the response in JSON string:

 {
  "privateKeyList":
     "[\"{key1:9315, key2:27108, key3:122 }\",
    \"{key1:9315, key2:27108, key3:122}\"]",

 "totalPrivateKey": 888  }
share|improve this question

By ref and by value

You are not creating a separate object for each item in your array. your array just holds a ref.

To get around this you can go to your repeat and add

ng-repeat="session in privateKeyList track by $index"

Objects

Should you need a new object for whatever reason you should just create it before you push to the array with Object.create

here is a link to a question that explains it.

share|improve this answer
    
not working ,broweser stuckup. – Parmar Kamlesh 21 hours ago

Use the track by $index with ng-repeat and Use ng-repeat with <tr> tag.

<tbody>
          <tr ng-repeat="session in privateKeyList" track by $index>
                                <td>{{session.ptID}}</td>
                                <td>{{session.encID}}</td>
                                <td>{{session.doctorID}}</td>

         </tr>
</tbody>

Use the track by $index with ng-repeat Example

<div ng-repeat="obj in collection track by $id(obj)">
  {{obj.prop}}
</div>

<div ng-repeat="n in [42, 42, 43, 43] track by $index">
  {{n}}
</div>

for more know
https://docs.angularjs.org/api/ng/directive/ngRepeat

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.