AngularJS orderBy指令不正确的结果

时间:2013-12-03 19:50:40

标签: angularjs

我有一个玩家列表,我试图先按等级排序,然后是玩家名称。这不是我得到的输出。我对orderBy filter的理解是可以接受一系列表达式。

<li ng-repeat="player in players | orderBy:['player.grade.number','player.first_name']">
     {{ player.grade.number }} - {{ player.first_name }}
</li>

http://plnkr.co/edit/h8Dlsmwi2mEqY9XzdRH7?p=preview

  $scope.players = [
    {
      "id":"91",
      "first_name":"Steve",
      "last_name":"Nickel",
      "grade":{
        "id":"7",
        "number":"7"
      }
    },
    ...

1 个答案:

答案 0 :(得分:4)

您不必使用player开始字符串:

<li ng-repeat="player in players | orderBy: ['grade.number','first_name']">

工作示例:http://plnkr.co/edit/QAmWayxwc5YXQEyPhbBI?p=preview