a8m / a8m/angular-filter

groupBy then orderBy

未關閉
#207 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
2.9k
分支
319
PR 合併指標
30 天內沒有已合併 PR

描述

I am using the groupBy filter, after groupBy filtering I would love to do orderBy filtering.
I have tried orderBy after the groupBy clause but that didn't work.

Can you extend your groupBy example(https://github.com/a8m/angular-filter#groupby) with the orderBy functionality.

My scenerio:
$scope.browsers = [
{UniquePageviews: 500, Browser: 'chrome'},
{UniquePageviews: 700, Browser: 'chrome'},
{UniquePageviews: 200, Browser: 'firefox'},
{UniquePageviews: 100, Browser: 'safari'},
{UniquePageviews: 250, Browser: 'safari'},
{UniquePageviews: 50, Browser: 'safari'},
{UniquePageviews: 0, Browser: 'opera'},
{UniquePageviews: 0, Browser: 'opera'},
{UniquePageviews: 1000, Browser: 'IE'},
{UniquePageviews: 800, Browser: 'IE'},
];

$scope.totalBrowserCount = function () {
var total = 0;
for (var i = 0; i < data.length; i++) {
var product = data[i].UniquePageviews;
total += product;
}
return total;
}


{{key}} {{(value | map: 'UniquePageviews' | sum) * 100 / totalBrowserCount() | number :0}}%

Above code groups the result and in the list it only shows each browser name. But as you can see few browsers have most unique visits (i.e. IE has 1800 in total), so I am expecting IE on the top of the list.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。