我有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
我试图通过list.id
(1,2,3等)达到最小到最大值
也许我无法通过list
订购?
答案 0 :(得分:1)
应该是,
<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>
答案 1 :(得分:0)
您在过滤器中缺少引号
GridView {
model: myModel
delegate: Text {
text: object.name(1)
}
}
<tr data-ng-repeat="list in customer.lists | orderBy: 'id' track by $index">
&#13;
var app = angular.module("app", []);
app.controller("ctrl", function($scope) {
$scope.customer = {
'lists': [{
id: 4,
name: 'T',
locations: []
}, {
id: 1,
name: 'S',
locations: []
}, {
id: 3,
name: 'R',
locations: []
}, {
id: 2,
name: 'O',
locations: []
}]
};
});
&#13;