xenurs
xenurs

Reputation: 449

retrieve data dynamically from several json array in angularjs

i get several json array and i want to retrieve some data in a loop. what i want is the value of the key count

Here is my code :

                .then(function(){
                    var tabuser = JSON.parse(localStorage.getItem("myid"));

                    for(i = 0; i < tabuser.length; i++){
                        console.log(tabuser[i].id);
                        displayfilter
                            .user(token,tabuser[i].id)
                            .then(function(data){

                                console.log(data);
                                $scope.numtickets = data;


                            })
                    }

                })

Here what i get from my `console.log(data):

enter image description here

And i want to retrieve the value of the key countfor every json array. How can i display that in my view ?

Upvotes: 0

Views: 198

Answers (1)

antish Gajwani
antish Gajwani

Reputation: 70

Create a json array:

$scope.numtickets = [];

Keep pushing the value of the keycount:

$scope.numtickets.push(data);

Display the array on the view:

<div ng-repeat="numticket in numtickets">
   {{numticket.count}}
</div>

Upvotes: 1

Related Questions