【发布时间】:2017-01-05 09:43:54
【问题描述】:
我正在开发一个使用 Ionic Angular 和 PHP 作为后端的应用程序。 我正在从 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: "
【问题讨论】:
-
你能告诉我们你的迭代代码吗?
-
@Hamooz 你能贴出你的角码吗?
-
{{oh.HistoryId}}
价格:{ {oh.TotalPrice }}
@vineet -
$scope.orderHistory= angular.toJson(response.data); @ashu jha
标签: php angularjs json ionic-framework