I have a multidimensional array from an API. Is it possible to programatically loop through the array?
{
success: true,
categories: [{
cat_id: 2,
name: This is category One,
description: null,
photo_url: /img/test.png,
order: 1,
items: [{
item_id: 1,
title: Desk,
item_url: /690928460,
photo_url: /desk.png,
}, {
item_id: 2,
title: Chair,
item_url: /18882823,
photo_url: /chair.png,
},
}]
}]
}
My controller looks like this:
myApp.controller('items', function($scope, $http, $location, Data) {
var apiUrl = '/api/items';
$http.get(apiUrl).
success(function(data) {
$scope.data = Data;
$scope.allData = data;
});
$scope.changeView = function(view) {
$location.path(view);
}
});
Angular index file just has: <div ng-view=></div>
View file
<div class=scrollable categories-container animated-fast slideInUp>
<div class=container categories>
<div class=row ng-repeat=categories in allData>
<div class=col-xs-6 ng-repeat=category in categories>
<div class=items>
<div class=title>
{{ category.name }}
</div>
</div>
</div>
</div>
</div>
</div>
I can loop through the category names fine, but when trying to return items for EACH category I don't understand the logic behind it...