[英]I'm developing an App using Ionic Angular and PHP for the backend. I am returning this JSON string from PHP and I'm receiving it as it is in Angular
我正在開發使用Ionic Angular和PHP作為后端的App。 我從PHP返回此JSON字符串,並且按Angular的方式接收它
[
{
"HistoryId":"440",
"TotalPrice":"24",
"aa":[{"orderid":"630","foodId":"1","quantity":"1","name":"Mixed Starter (Minimum For Two)","price":"9"}, {"orderid":"641","foodId":"3","quantity":"1","name":"Sesame chicken on toast","price":"5"},
{"orderid":"662","foodId":"2","quantity":"2","name":"Sesame prawn on toast","price":"5"}]
},
{
"HistoryId":"451",
"TotalPrice":"24",
"aa":[{"orderid":"650","foodId":"1","quantity":"1","name":"Mixed Starter (Minimum For Two) ","price":"9"}, {"orderid":"671","foodId":"3","quantity":"1","name":"Sesame chicken on toast","price":"5"},
{"orderid":"682","foodId":"2","quantity":"2","name":"Sesame prawn on toast","price":"5"}]
}
]
但是當我嘗試顯示它時,我收到此錯誤:
Error: [ngRepeat:dupes] Duplicates in
a repeater are not allowed. Use 'track by' expression
to specify unique keys. Repeater: oh in orderHistory,
Duplicate key: string:", Duplicate value: "
用這個
<ion-item ng-repeat="oh in orderHistory track by $index" > <h2>{{oh.HistoryId}} </h2> <h3 style="color:green">Price: {{oh.TotalPrice }}</h3> <ion-card> <ion-item ng-repeat="o in oh.aa ">
AngularJS不允許在ng-repeat指令中重復
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.