Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I can't find a way to loop through my array of json objects with angular .

My array looks like that in firebug(Each series of objects have an index value.):

 [[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...}]

It has been produced by this code :

        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;
    };

And the html is :

<div ng-repeat="idliste in listeCommandes" >
        <div ng-repeat="(nom, id) in idliste">
             {{nom}} : {{id}}
        </div>
</div>

It doesn't work. I really can't figure how to make it work, it means, simply print each objects, following the index number.

THank you if u got any idea. I've searched the forums but can't find any solution. Maybe it's the way i 've created an index that is wrong ?

share|improve this question
    
could you please create a plukr/fiddle, its really hard to understand by looking at code –  pankajparkar 49 mins ago
    
Ok ! Thank you. –  nicolas huleux 41 mins ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.