0
我有这样的对象数组的数组,我从结果中传递出来的对象数组;为什么我的ng-repeat只显示第一个结果?
[
[
{
"id": 4,
"name": "THROTTLE TUBE",
"partno": "104-",
"oemnumber": "46019 038",
"stock": 19,
"price": "28"
},
{
"id": 28,
"name": "TACHOMETER, CUP",
"partno": "128-",
"oemnumber": "25012 011",
"stock": 7,
"price": "46"
}
]
]
我从下面得到这个;
$scope.woParts = [];
//later in my modal code - which is where the double [] is coming from
modalInstance.result.then(function(woParts) {
$scope.woParts.push(woParts);
我然后在我的视图中使用这个ng-repeat;
<div ng-repeat="woPart in woParts">
<div class="col-md-4">
@{{ woPart[$index].name }}
</div>
<div class="col-md-2">
@{{ woPart[$index].oemnumber }}
</div>
<div class="col-md-2">
@{{ woPart[$index].price | currency}}
</div>
<div class="col-md-2">
<input type="number"
class="form-control"
ng-model="partQty">
</div>
</div>
这只显示数组中的第一个结果。这是为什么? 谢谢!
我可以问你为什么把双[]在JSON,如果有一个我认为它工作正常 – abdoutelb
好问题。检查我的编辑... – RushVan
尝试使用{{woPart.name}} “woPart”,我明白指数组中的对象不使用索引 – abdoutelb