2015년 1월 1일 목요일

[AngularJS] ngRepeat dupes error even JSON is having single object

Iam getting below error when iam trying to use ng-repeat to traverse the JSON object which is returned from JSP through an ajax call from angular service. Attched all the files that iam using

Error: [ngRepeat:dupes] http://errors.angularjs.org/1.2.28/ngRepeat/dupes?p0=cata%20in%20categories123&p1=string%3A%22&p2=%22%5C%22%22
z/<@http://localhost/webapp/wcs/stores/AngularJS/js/angular.min.js:6:450
xd</<.link/<@http://localhost/webapp/wcs/stores/AngularJS/js/angular.min.js:201:179
Yd/this.$get</h.prototype.$watchCollection/<@http://localhost/webapp/wcs/stores/AngularJS/js/angular.min.js:109:293
Yd/this.$get</h.prototype.$digest@http://localhost/webapp/wcs/stores/AngularJS/js/angular.min.js:110:371
Yd/this.$get</h.prototype.$apply@http://localhost/webapp/wcs/stores/AngularJS/js/angular.min.js:113:360
m@http://localhost/webapp/wcs/stores/AngularJS/js/angular.min.js:72:452
w@http://localhost/webapp/wcs/stores/AngularJS/js/angular.min.js:77:463
ye/</B.onreadystatechange@http://localhost/webapp/wcs/stores/AngularJS/js/angular.min.js:79:24
"

AngularJS.zip

com.zip



Can pls someone provide any hint on this issue




In the below code, string is assigned to the variable responseList.
var responseList = JSON.stringify(data.categories);
alert(responseList);
$scope.categories123 = responseList ;

.. and you are using it in ng-repeat, which will probably be considered as a character array which might be having duplicate characters. Convert responseList to an array using angular.fromJson() method and check.
<div ng-repeat="cata in categories123">{{cata.Name}}{{cata.id}}</div>


댓글 없음:

댓글 쓰기