ng-repeat witih segreation
by Alaksandar Jesus Gene
HTML
<div ng-app="newApp" ng-controller="myCtrl">
<ul> Fresh Food
<li>435678</li>
</ul>
</div>
CSS
li{
margin-left:40px;
}
JavaScript
myApp = angular.module("newApp",[]);
myApp.controller("myCtrl",function($scope){
$scope.products = [
{deptName:"Fresh food",item: {productid:4356178}},
{deptName:"drinks",item: {productid:4356179}},
{deptName:"Fresh food",item: {productid:4356180}},
{deptName:"drinks",item: {productid:4356181}}
];
var newProducts=[];
var tempArray=[];
for(var i=0; i<$scope.products.length;i++){
if(tempArray.indexOf($scope.products[i].deptName)==-1){
tempArray.push($scope.products[i].deptName);
}
};
angular.forEach(tempArray,function(values){
newProducts.push({key:values,items:[]});
});
angular.forEach(newProducts,function(values){
for(var i=0; i<$scope.products.length;i++){
}
console.log(values.key);
})
});