This code snippet is from the controller:
cat1=[];
$.getJSON('categories/1/', function(data) {
cat1 = data; //this returns a JSON object
});
//cat2..4 are also JSONs
$scope.pictures=[cat1,cat2,cat3,cat4,cat5];
The issue here seems to be that cat1=[]
and cat1=data
might not be treated as the same variable, leading to pictures[cat1]
always returning an empty array.
Could there be something incorrect in my code logic?