1
我无法找到一种方式来循环浏览json对象数组。以ng-repeat角度循环遍历一个对象数组
我的阵列看起来像在萤火(每个系列的对象具有的索引值。):
[[0], Object { idliste=0, id=1, photo="pot.jpg", plus...}, Object { idliste=0, id=3, photo="pot.jpg", plus...}]
[[1], Object { idliste=1, id=1, photo="pot.jpg", plus...}, Object { idliste=1, id=3, photo="pot.jpg", plus...}]
[[2], Object { idliste=2, id=1, photo="pot.jpg", plus...}, Object { idliste=2, id=3, photo="pot.jpg", plus...}]
已经由此代码生成:
var idListe = $scope.getIdListe();
$scope.listeCommandes[idListe]= new Array([idListe]);
for (i=0;i<$scope.panier.length;i++){
$scope.listeCommandes[idListe].push({
idliste:idListe,
id: $scope.panier[i].id,
photo: $scope.panier[i].photo,
nom: $scope.panier[i].nom,
quantite:$scope.panier[i].quantite,
prix: $scope.panier[i].prix,
heureajout:$scope.getHeure()
});
};
$scope.getIdListe = function(){
var idListe = $scope.listeCommandes.length;
return idListe;
};
和HTML是:
<div ng-repeat="idliste in listeCommandes" >
<div ng-repeat="(nom, id) in idliste">
{{nom}} : {{id}}
</div>
</div>
它不起作用。我真的不知道如何使它工作,这意味着,只需按照索引号打印每个对象即可。
谢谢你,如果你有任何想法。我搜索了论坛,但找不到任何解决方案。也许这是我创建一个错误的索引的方式?
能否请您创建一个plukr /小提琴,它真的很难通过观察代码 – 2015-04-05 10:32:31
好理解!谢谢。 – 2015-04-05 10:39:57