0
angular.forEach($scope.lista, function(data) {
  console.log(data);
  $scope.listaCliente = data.listaClienteMaquina;
  console.log($scope.listaCliente);
});

being that when I access the array of $ scope.listaCliente, it returns undefined, someone help me? : /

1
  • Also add the array $scope.lista Commented Jun 12, 2015 at 16:09

2 Answers 2

1

being that when I access the array of $scope.listaCliente, it returns undefined

One thing I am sure of is if $scope.listaCliente is an array then you need to push into it. Currently you are reassigning it every-time your loop runs.

$scope.listaCliente.push(data.listaClienteMaquina);

I hope you also initialized the array outside like

$scope.listaCliente = [];
Sign up to request clarification or add additional context in comments.

2 Comments

when I use console.log (data), it just right shows the objects and the listaClienteMaquina array and what's in it, but when I put console.log (data.listaClienteMaquina), it returns undefinied
@LucasPadilha Can you add the content of your data in your question.
0

You are iterating all of the properties of the object $scope.lista instead of the array collection listaClienteMaquina.

You can test it here http://codepen.io/leandroh/pen/RPgvwP

Avoid $watch and use ng-change.

Details in this post http://www.benlesh.com/2013/10/title.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.