我正在显示id
排序的列表,其中包含以下代码:
<dl class="dl-horizontal" ng-repeat="projectManager in projectManagers| orderBy: 'id'">
<dt>{{projectManager.id}}</dt>
<dd>{{projectManager.givenname}} {{projectManager.surname}}</dd>
</dl>
但这些想法按字母顺序排列:
1
11
13
21
25
3
35
如何以数字方式订购?
答案 0 :(得分:1)
您可以将自定义功能传递给orderBy
:
<dl class="dl-horizontal" ng-repeat="projectManager in projectManagers| orderBy: parseLikeAPro">
并在控制器中:
$scope.parseLikeAPro = function(pm) {
return pm.id | 0;
}