Below is my plunker where I have tried to display the data under each category.But the data are not printing as supposed to .Example:-rom value 12345 should come directly under bread. I'm not sure where I'm doing wrong in my code:
$scope.allProducts = [];
angular.forEach($scope.data,function(item, index){
angular.forEach(item.products, function(item2, index){
if($scope.allProducts.indexOf(item2.consummable) == -1){
$scope.allProducts.push(item2.consummable);
}
})
})
The solution for what you need is the following:
1) keep the allProducts generation like this:
2) Add this in your controller:
3) The table generation will be:
Yet another variant with changed
ng-repeat
expression. Since you repeat allProducts in first line, you need repeat it and in others, and filter data for selected value. See code snippet belowPlease check the structure :
And just push item2 in allProducts instead of consummable field only :
})
Plunker : http://plnkr.co/edit/YWPL2EmKK6MIwIkevZ1W?p=preview