I have an array of People I need to filter and order by against two criteria. My filter is simple in that if the name contains what they're typing let it through. For grouping, I want to group all of the people with clockedIn=1 first, and then within those two groups I want to order by last name.
我有一系列的人,我需要根据两个标准进行过滤和排序。我的过滤器很简单,如果名称包含他们正在输入的内容,请通过。对于分组,我想首先用clockedIn = 1对所有人进行分组,然后在这两个组中我想按姓氏排序。
My filter is working perfectly but I cannot seem to get orderBy to work at all no matter what I do...
我的过滤器工作得很完美,但无论我做什么,我似乎都无法完成任务...
Full jsfiddle: http://jsfiddle.net/joshuaohana/82k76uj0/1/, shows all helper functions and whatnot
完整的jsfiddle:http://jsfiddle.net/joshuaohana/82k76uj0/1/,显示所有帮助函数和诸如此类的东西
The repeat I'm trying to setup:
我正在尝试设置的重复:
<div ng-repeat="person in people | filter:nameFilterFn | orderBy: '+person.clockedIn' | orderBy:'-person.userLastName' ">
<p>{{person.userName}}</p>
<p>{{person.clockedIn}}</p>
</div>
For an ng-repeat, how do I...
对于ng-repeat,我该怎么做...
- Filter against a function
- First sort by a boolean in the ng-repeat
- Secondly sort against the user's last name
过滤功能
首先按ng-repeat中的布尔值排序
其次,根据用户的姓氏进行排序
1 个解决方案
#1
1
To sort by multiple field use this syntax:
要按多个字段排序,请使用以下语法:
<div ng-repeat="person in people | filter:nameFilterFn | orderBy: ['clockedIn', 'userLastName'] ">
To use reversed lastName
use ['clockedIn', '-userLastName']
要使用反向的lastName,请使用['clockedIn',' - userLastName']
Updated fiddle here
这里更新了小提琴
#1
1
To sort by multiple field use this syntax:
要按多个字段排序,请使用以下语法:
<div ng-repeat="person in people | filter:nameFilterFn | orderBy: ['clockedIn', 'userLastName'] ">
To use reversed lastName
use ['clockedIn', '-userLastName']
要使用反向的lastName,请使用['clockedIn',' - userLastName']
Updated fiddle here
这里更新了小提琴