Angular ng-repeat groupBy和Keep order

Har*_*rry 16 javascript html5 angularjs angularjs-directive ionic-framework

我使用这个过滤器https://github.com/a8m/angular-filter#groupby来订购我的数据,这样做很好:

<div ng-repeat="(key, value) in tags.tags.objects | groupBy:'category.name' ">
Run Code Online (Sandbox Code Playgroud)

现在我试图通过category.order保持这些组的顺序.

这可能吗?

我试过像这样管道:

<div ng-repeat="(key, value) in tags.tags.objects | groupBy:'category.name' | orderBy:'category.order' ">
Run Code Online (Sandbox Code Playgroud)

但它没有任何区别

a8m*_*a8m 18

orderBy过滤器不适用于对象ngRepeat.那么,你能做的是这样的:

<!-- 
     Note: toArray filter also attaches a new property $key
     to the value containing the original key that was used in the object. 
-->

<div ng-repeat="tags in tagsList | groupBy:'prop' | toArray:true | orderBy:'$key'">
  Group name: {{ tags.$key }}
  <p ng-repeat="tag in tags | orderBy:'prop'">
     {{ tag.name }}
  </p>
</div>
Run Code Online (Sandbox Code Playgroud)

请参阅:toArray过滤器