Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

javascript - 在Angular中有多个字段(orderBy multiple fields in Angular)

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 - 1)

1 - 2(1 - 2)

1 - 20(1 - 20)

2 - 1(2 - 1)

2 - 10(2 - 10)

2 - 11(2 - 11)

<select ng-model="divs" ng-options="(d.group+' - '+d.sub) for d in divisions | orderBy:'group' | orderBy:'sub'" />
  ask by gmeka translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Please see this:(请看这个:)

http://jsfiddle.net/JSWorld/Hp4W7/32/(http://jsfiddle.net/JSWorld/Hp4W7/32/)

<div ng-repeat="division in divisions | orderBy:['group','sub']">{{division.group}}-{{division.sub}}</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...