如何按日期分隔ng-repeat

时间:2015-01-29 19:09:38

标签: javascript angularjs

我疯狂地创建一个按年份和月份名称分隔的列表...

我希望有类似的东西:

Events in 2015
January
- event 1
- event 2
- event 3
February
- event 1
- event 2
...ecc...
Events in 2016
...ecc...

我不认为我必须为每个年份和月份创建一个中继器,对吧?我认为有一个过滤器或规则来实现这一点。

<div ng-app ng-controller="Main">
   <div ng-repeat="event in events | what here?">
        // how to create separators here?
        {{event.title}}
   </div>
</div>


$scope.events = [
    {id: 1, title: "Title 1", date: 283764873126}, 
    {id: 2, title: "Title 2", date: 283764873126}, 
    {id: 3, title: "Title 3", date: 283764873126}, 
    {id: 4, title: "Title 4", date: 283764873126}
];

0 个答案:

没有答案