I have an array with two objects in it, assigned to $scope.items;
when i do
console.log($scope.items)
the output is:
[
{s: "item1", q: 3, $$hashKey: "object:3", population: Object},
{s: "item2", q: 3, $$hashKey: "object:4", population: Object}
]
but when i do
console.log($scope.items[0])
the output (sometimes*) is:
{s: "item1", q: 3, $$hashKey: "object:3"}
'* this does not always happen, depends on page load. when refreshing the page, the result is some times with the population and sometimes without.
the first output is always complete with the population intact. (no matter how manny times i press f5 :) )
i call the console.log at the same time. and in the same order as above.
so i dont understand when i call one of the objects directly they are incomplete?
it looks like a parsing error, but how can the first output always be complete?
Extra info the $scope.items is a copy of another array.
i use $http.get to build the object, but also tried to call the console.logs in his success functions.
the $http.get is placed inside a foreach so is called multiple times before the the complete array is complete
and i use the http.get to build the population.
i hope someone can clarify this a bit for me, how this can be possible. or howto continue to look for possibilities to find the error.
$scope.items? and fill population?console.log($scope.items)it's logging by reference but when you doconsole.log($scope.items[0])it's logging by value, try and doconsole.log(angular.copy($scope.items))$httpin success method I alter the object and then infinallyi console.log it and it will ALWAYS be in correct format