Search code examples
angularjsangularjs-ng-repeatangular-filters

GroupBy date using angular-filter lib


I'm using angular-filter lib's GroupBy to group data in ng-repeat. The problem is that date is rapresented as: 2015-10-09T19:00:00+0200. So data will be also grouped based on hours and minutes instead of only date.

<div ng-repeat="(key, value) in events.data | groupBy: 'startTime'">

How can exclude hours and take just dates?

Thanks.


Solution

  • You can create a formatter method for the dates in controller and use that while grouping.

    E.g

    vm.formatDate(datetime) is our formatter method in controller.

    <div ng-repeat="(key, value) in events.data | groupBy: 'vm.formatDate(startTime)'">
    

    I hope it helps.