I have declared it as below and also showing data is actually coming from the server but the following code doesn't work if there are multiple arrays in the data coming from the server.
$scope.items = [ { id: “”, locations: [{ name: “” }] } ] Data from server looks this way. $scope.data = [ { id: '1', type: 'a1', year: '1999', locations: [ {id:'1', name: 'abc'}, {id:'11', name: 'xyz'}] }, { id: '11', type: 'a2', year: '2000', locations: [ {id:'22', name: 'abc1'}, {id:'23', name: 'xyz1'}, {id:'24', name: 'efg1'}] } ... ]
for (var i=0; i<$scope.data.length; i++) { $scope.items[i].id = $scope.data[i].id; for(var j=0; j<$scope.data[i].locations.length; j++) { $scope.items[i].locations[j].name = $scope.data[i].locations[j].name; } }