I am trying to group elements into ng-repeat using a condition.
An example is the combination of all elements with the same hour.
Data:
[ {name: 'AAA', time: '12:05'}, {name: 'BBB', time: '12:10'}, {name: 'CCC', time: '13:20'}, {name: 'DDD', time: '13:30'}, {name: 'EEE', time: '13:40'}, ... ]
The time field is actually a timestamp (1399372207), but with the exact time, the output of the example is easier to understand.
I list these elements using ng-repeat:
<div ng-repeat="r in data| orderBy:sort:direction"> <p>{{r.name}}</p> </div>
also tried:
<div ng-repeat-start="r in data| orderBy:sort:direction"></div> <p>{{r.name}}</p> <div ng-repeat-end></div>
Valid is:
<div class="group-class"> <div><p>AAA</p></div> <div><p>BBB</p></div> </div> <div class="group-class"> <div><p>CCC</p></div> <div><p>DDD</p></div> <div><p>EEE</p></div> </div>
My last option, if there is no easy solution for my problem, is to group the data and then assign it to the variable of the region used in ng-repeat.
Any thoughts?
angularjs angularjs-ng-repeat ng-repeat
Catalin MUNTEANU May 6 '14 at 11:09 a.m. 2014-05-06 11:09
source share