这是我的代码
ng-repeat="item in records"
{{item.listingname}}
我收到了这个错误 -
错误:[ngRepeat:dupes]不允许在转发器中重复。使用 '跟踪'表达式以指定唯一键。中继器:项目 记录,重复键:字符串:i,重复值:i
如何从这个json获取数据
[{"position":1,"listingmasterid":"20120","listingname":"Prabhu Traders.","recommended_flag":"advantage-mark","recommended_title":"Verified and Recommended","search_type":"area0-sibling","areamasterid":"148","avgrating":5,"ratingcount":"29","listingphones":"9860435060,9422717367","uniqueid":"145561808456c2f8242e485","countryid":"99","stateid":"1493","cityid":"39","areaid":"148","address":"","address2":"Jalgaon Aurangabad Bypass Road","landmark":"Beside Wheel Alignment ","website":"","mobile":"9860435060","mobile2":"9422717367","stdcode":"","landline1":"","email":"","zipcode":"431112","aboutlisting":"","is_active":"1","is_paid":"1","is_publish":"Y","is_private":"Y","is_verified":"1","totalrrcount":"489","countryname":"India","statename":"Maharashtra","cityname":"Aurangabad (MS)","areaname":"Sillod","url":"http://callme.co.in/en/aurangabad/prabhu-traders-_aUXnAwZE/592656/36818266/39802?kp=2?ut=M","relevance_boolean":"","relevance_natural":""},{"position":2,"listingmasterid":"6795","listingname":"RISHI AGRO","recommended_flag":"freeverified-mark","recommended_title":"Verified and Recommended","search_type":"area0-sibling-fv","areamasterid":"66","avgrating":4,"ratingcount":"1","listingphones":"9322228050,9004049974","uniqueid":"187b38ba-47d7-11e5-966f-7071bcbcf6ed","countryid":"99","stateid":"1493","cityid":"39","areaid":"66","address":"64-A ","address2":"NEW SHANTI NIKETAN COLONY","landmark":" BEHIND AIR TRIMURTI CHOWK","website":"rishibiotech.com","mobile":"9322228050","mobile2":"9004049974","stdcode":"0240","landline1":"","email":"","zipcode":"","aboutlisting":"","is_active":"1","is_paid":"0","is_publish":"Y","is_private":"Y","is_verified":"1","totalrrcount":"38","countryname":"India","statename":"Maharashtra","cityname":"Aurangabad (MS)","areaname":"Jawahar Colony","url":"http://callme.co.in/en/aurangabad/rishi-agro-187b38ba-47d7-11e5-966f-7071bcbcf6ed/592656/36818267/39802?kp=1?ut=M","relevance_boolean":"","relevance_natural":""}]
答案 0 :(得分:1)
为避免重复,请使用$ index
跟踪<p ng-repeat="item in records track by $index">{{item.listingname}}</p>
<强> DEMO 强>
答案 1 :(得分:1)
您可以使用此代码并将 MyCtrl 替换为您的控制器名称
<body ng-controller="MyCtrl"> <div ng-repeat="value in records track by $index"> <h1>{{value.listingname}}</h1> </div> </body>