在ng-repeat中的angularjs中的orderBy

时间:2016-05-13 07:23:34

标签: angularjs angularjs-orderby

我不明白为什么它不起作用你知道为什么orderBy'-nbtickets'不能正常工作吗?

  <ul ng-repeat="item in customarray | orderBy:'-nbtickets' track by $index">
    <li ui-sref="app.usersingle({id:item[0].id,iterate:1})" class="row organization">
      <div class="col-md-2 classement text-center">{{$index+1}}</div>
      <div class="name col-md-4 text-center">{{item[0].username}}</div>
      <div class="col-md-2 total text-center">{{item[0].nbtickets}}</div>
      <div class="col-md-2 maintenance text-center">{{item[0].tickmaintenance}}</div>
      <div class="col-md-2 assistance text-center">{{item[0].tickassistance}}</div>
    </li>
  </ul>

在我的控制器中,我就是这样做的:

$scope.customarray = data;

这里的数组我通过{{item}}显示它(我的数组的解析是很大的)

[
  {"username":"Eugenie Martin","tickassistance":4,"tickbug":0,"tickmaintenance":3,"nbtickets":7,"id":660302971,"tickets":[{"date":"2015-09-29T07:12:14Z","titre":"Changement date de clôture dossier Barbe Alain","status":"closed","tag":"maintenance"},
  {"date":"2015-09-04T09:45:20Z","titre":"43325- NH DISTRIBUTION","status":"closed","tag":"assistance"},
  {"date":"2015-08-20T06:18:04Z","titre":"TR: EURL NH DISTRIBUTION vous a envoyé un message depuis sa plateforme","status":"closed","tag":"assistance"},{"date":"2015-02-25T16:00:46Z","titre":"Votre demande au support sans suite","status":"closed","tag":"assistance"},
  {"date":"2015-01-12T06:48:35Z","titre":"Bonjour,\n\nle cabinet AUFICOM aura un stand lors du...","status":"closed","tag":"assistance"},
  {"date":"2014-12-18T09:48:38Z","titre":"ISACOMPTA","status":"closed","tag":"maintenance"},{"date":"2014-12-15T14:08:08Z","titre":"changement date de clôture","status":"closed","tag":"maintenance"}],
  "monthly":[{"now11":0,"assist":0,"maint":0},
  {"now10":0,"assist":0,"maint":0},
  {"now9":1,"assist":1,"maint":0},
  {"now8":2,"assist":1,"maint":1},
  {"now7":0,"assist":0,"maint":0},
  {"now6":0,"assist":0,"maint":0},
  {"now5":0,"assist":0,"maint":0},
  {"now4":0,"assist":0,"maint":0},
  {"now3":0,"assist":0,"maint":0},
  {"now2":0,"assist":0,"maint":0},
  {"now1":0,"assist":0,"maint":0},
  {"now":0,"assist":0,"maint":0}]},
  [{"date":"2015-09-29T07:12:14Z","titre":"Changement date de clôture dossier Barbe Alain","status":"closed","tag":"maintenance","id":660302971,"name":"Eugenie Martin"},
  {"date":"2015-09-04T09:45:20Z","titre":"43325- NH DISTRIBUTION","status":"closed","tag":"assistance","id":660302971,"name":"Eugenie Martin"},
  {"date":"2015-08-20T06:18:04Z","titre":"TR: EURL NH DISTRIBUTION vous a envoyé un message depuis sa plateforme","status":"closed","tag":"assistance","id":660302971,"name":"Eugenie Martin"},
  {"date":"2015-02-25T16:00:46Z","titre":"Votre demande au support sans suite","status":"closed","tag":"assistance","id":660302971,"name":"Eugenie Martin"},
  {"date":"2015-01-12T06:48:35Z","titre":"Bonjour,\n\nle cabinet AUFICOM aura un stand lors du...","status":"closed","tag":"assistance","id":660302971,"name":"Eugenie Martin"},
  {"date":"2014-12-18T09:48:38Z","titre":"ISACOMPTA","status":"closed","tag":"maintenance","id":660302971,"name":"Eugenie Martin"},
  {"date":"2014-12-15T14:08:08Z","titre":"changement date de clôture","status":"closed","tag":"maintenance","id":660302971,"name":"Eugenie Martin"}]
];

2 个答案:

答案 0 :(得分:0)

您是否尝试过orderBy:-item[0].nbtickets

答案 1 :(得分:0)

你试过吗?

<ul ng-repeat="item in customarray | orderBy:'nbtickets':true track by $index">

角度orderBy中有一个反向选项,它是上面的:true部分。