My task is to display a list organized by date, but the problem is that the list is not sorted and I can't figure out when the date changes. This situation is similar to having the following Json:
list =
{name: first, date: 2014-05-21}, {
{name: second, date: 2014-05-20}, {
{name: third, date: 2014-05-21}
I want to generate the corresponding html structure:
<li><h3>2014-05-21</h3>
<ul>
<li>first</li>
<li>third</li>
</ul>
</li>
<li><h3>2014-05-20</h3>
<ul>
<li>second</li>
</ul>
</li>
Any suggestions on how to achieve this?
I attempted to create an Array of arrays using two ng-repeat loops like so:
for (i in list){
if ($scope.listToShow[list.date] == undefined) {
$scope.listToShow[list.date] = newArray();
}
$scope.listToShow[list.date].push(list[i]);
}
However, I'm struggling to actually display the result.