var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.groupedMedia = {};
$scope.groupedMedia['2014_January'] = [{name:'file1', lastModified:'20-Jan-2014'},{name:'file2', lastModified:'21-Jan-2014'}];
$scope.groupedMedia['2013_December'] = [{name:'file1', lastModified:'20-Jan-2013'},{name:'file2', lastModified:'20-Apr-2013'}];
console.log($scope.groupedMedia); //This will provide an output like below.
//{'2014_January': Array[5], '2013_December': Array[95]}
$scope.groupKeys = function(data){
return Object.keys(data);
}
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>
document.write('<base href="' + document.location + '" />');
</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.16/angular.js" data-semver="1.2.16"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
Normal:
<div ng-repeat="(group, files) in groupedMedia">
{{group}}
<div ng-repeat="file in files">
<p>{{file.name + ': '+ file.lastModified}}</p>
</div>
</div>
Actual Map order:
<div ng-repeat="key in groupKeys(groupedMedia)">
{{key}}
<div ng-repeat="file in groupedMedia[key]">
<p>{{file.name + ': '+ file.lastModified}}</p>
</div>
</div>
</body>
</html>
/* Put your css in here */