在角排序依据多个字段 [英] orderBy multiple fields in Angular
本文介绍了在角排序依据多个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过使用多个字段在角度同时进行排序?拳经组,然后由亚组
例如:
$ scope.divisions = {'组':1,'子':1},{'组':2,'子':10},{'组' :1,'子':2},{'组':1,'子':20},{'组':2,'子':1},
{'组':2,子:11}];
我想显示此为
组:分组
1 - 1
1 - 2
1 - 20
2 - 1
2 - 10
2 - 11
<选择NG模型=申报单NG选项=(d.group +' - '+ d.sub)在部门开发|排序依据:'群'|排序依据:'子'/>
解决方案
请看到这一点:
http://jsfiddle.net/JSWorld/Hp4W7/32/
< DIV NG重复=,在师师|排序依据:['群','分']> {{division.group}} - {{师。子}}< / DIV>
How to sort by using multiple fields at same time in angular? fist by group and then by sub-group for Example
$scope.divisions = [{'group':1,'sub':1}, {'group':2,'sub':10}, {'group':1,'sub':2},{'group':1,'sub':20},{'group':2,'sub':1},
{'group':2,'sub':11}];
I wanted to display this as
group : Sub-group
1 - 1
1 - 2
1 - 20
2 - 1
2 - 10
2 - 11
<select ng-model="divs" ng-options="(d.group+' - '+d.sub) for d in divisions | orderBy:'group' | orderBy:'sub'" />
解决方案
Please see this:
http://jsfiddle.net/JSWorld/Hp4W7/32/
<div ng-repeat="division in divisions | orderBy:['group','sub']">{{division.group}}-{{division.sub}}</div>
这篇关于在角排序依据多个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文