ng-repeat 中 angularjs 中的 orderBy
orderBy in angularjs in ng-repeat
我不明白为什么它不起作用你知道为什么 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"}]
];
你试过了吗orderBy:-item[0].nbtickets
?
你试过了吗?
<ul ng-repeat="item in customarray | orderBy:'nbtickets':true track by $index">
angularorderBy
中有一个反向选项,也就是上面的:true
部分。
我不明白为什么它不起作用你知道为什么 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"}]
];
你试过了吗orderBy:-item[0].nbtickets
?
你试过了吗?
<ul ng-repeat="item in customarray | orderBy:'nbtickets':true track by $index">
angularorderBy
中有一个反向选项,也就是上面的:true
部分。