我打印出來的數據有問題。不能顯示AngularJS中的數組數據
我
{{orders}} =
[{"item":"DELL","quantity":6,"price":144},
{"item":"Samsung","quantity":3,"price":3131},
{"item":"222222","quantity":1,"price":31},
{"item":"111111111","quantity":1,"price":13}]
我嘗試查看
<div ng-repeat="order in orders track by $index">
<span>{{ order[$index].item }}
</span>
</div>
並沒有什麼。有人可以幫助我嗎?
編輯: 還不行
{{訂單}}
<div ng-repeat="order in orders track by $index">
<span>
{{order.item}}
</span>
並沒有什麼
控制器:
$scope.ListOfOrders = function() {
return ApiService.cart.list().then(function (resp) {
$scope.orders = resp[0].order;
console.log(resp[0].order)
});
}
order是數組中的項目,所以'{{order.item}}或'{{orders [$ index] .item}}'顯示該項目。 – Fetrarij
學習一些教程 – charlietfl