angular-filter icon indicating copy to clipboard operation
angular-filter copied to clipboard

Does the groupBy doesn't works correctly with native orderBy filter?

Open tavai89 opened this issue 9 years ago • 3 comments

Looks like when I trying to use native angular orderBy filter along with the groupBy filter the first doesn't affect the result:

ng-repeat="(key, value) in collection | orderBy: '-OccurredOnDate' | groupBy: groupBy"

Any thoughts?

Thanks in advance

tavai89 avatar Aug 25 '15 15:08 tavai89

Hi @tavai89 PTAL on issue-26, and let me know if there's any questions. Thanks.

a8m avatar Aug 25 '15 18:08 a8m

Hi @a8m

Firstly, thank you a lot for your response. I have found the solution for my issue here:

https://github.com/a8m/angular-filter/issues/57

In the jsbin you have posted:

http://jsbin.com/hopowowodu/1/edit?html,js,output

The solution was:

ng-repeat="group in collection | groupBy: groupBy | toArray:true | orderBy: '-$key'"

since I wanted to order the groups, not the items in groups.

Thank you

tavai89 avatar Aug 26 '15 10:08 tavai89

Performance of toArray:true solution is bad with angular 1.4.8.

Do you have another/better solution in 2017 for me?

solidevolution avatar Mar 28 '17 11:03 solidevolution