JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="myApp">
<div ng-controller='TestGroupingCtlr'>
<div ng-repeat='group in getGroups()'>
<h2>{{group}}</h2>
<ul>
<li ng-repeat="item in MyList | groupby:group">{{item.whatever}}</li>
</ul>
</div>
</div>
</div>
JavaScript
var app=angular.module('myApp',[]);
app.filter('groupby', function(){
return function(items,group){
return items.filter(function(element, index, array) {
return element.GroupByFieldName==group;
});
}
})
app.controller('TestGroupingCtlr',function($scope) {
$scope.MyList = [{ GroupByFieldName: 'Group 1', whatever: 'abc'},
{GroupByFieldName: 'Group 1',whatever: 'def'},
{GroupByFieldName: 'Group 2',whatever: 'ghi' },
{GroupByFieldName: 'Group 2',whatever: 'jkl'},
{GroupByFieldName: 'Group 2',whatever: 'mno' }
];
$scope.getGroups = function () {
var groupArray = [];
angular.forEach($scope.MyList, function (item, idx) {
if (groupArray.indexOf(item.GroupByFieldName) == -1) groupArray.push(item.GroupByFieldName)
});
return groupArray.sort();
}
})