gpt4 book ai didi

javascript - orderBy 未正确过滤数字

转载 作者:行者123 更新时间:2023-12-03 05:01:23 25 4
gpt4 key购买 nike

我有一个 ng-repeat 指令。

<tr data-ng-repeat="list in vm.customer.lists | orderBy: list.id track by $index">
<td>[[list.name]]</td>
<td>[[list.locations.length]] Location<span data-ng-cloak data-ng-if="list.locations.length !== 1">s</span></td>
<td><a data-ng-href="/#/locations/manage/list/edit/[[vm.customer.id]]/[[list.id]]" class="button expand">Manage Locations</a></td>
</tr>

我在 vm.customer.lists 中重复 3 个列表

我试图通过list.id(1、2、3等)完成从最小到最大的任务

也许我无法按 list 排序?

最佳答案

应该是

<tr data-ng-repeat="list in vm.customer.lists | orderBy: 'id' ">

演示

var app = angular.module("app", []);
app.controller("ctrl", function($scope) {
$scope.customer =
[{
id: 4,
name: 'sachin'

}, {
id: 1,
name: 'Saurav'

}, {
id: 3,
name: 'Dravid'

}, {
id: 2,
name: 'Dhoni'

}];

});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
<li ng-repeat="list in customer | orderBy: 'id' track by $index">
{{list.name}}
</li>

</div>

关于javascript - orderBy 未正确过滤数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42210174/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com