Here is a general idea :
This is like paging. Get a decade from all your records (events), and then group them into pages (one per decade). Once your repeater relies on this eventsByDecade array, angularjs will do all the heavy lifting.
Here are some suggestions:
After filling in the events variable with your json file, create an array and fill it depending on the dates. To do this, you will need to check event.theDate.getFullYear() on each event.
Then, depending on the year, you can get ten years, possibly using year.substring(0,2) (use only the first 3 digits).
Then, group them by decade in an array, and then assign each decimal array to the eventsByDecade array.
Finally, change the repeater to:
ng-repeat="event in events | filter:query | orderBy:orderProp:true"
to use your "paged" array:
ng-repeat="event in eventsByDecade[currentIndex] | filter:query | orderBy:orderProp:true"
Here, currentIndex will be set whenever links are currentIndex , for example:
<li><a href="#decade-1960s" ng-click="currentIndex = 1">1960</a></li>
Update: json manipulation
JSON evaluates JavaScript objects. So you can iterate over your events as follows:
for(var event in events){ event.theDate;
Ulises
source share