在以下情况中,orderBy
过滤器不适用于point
属性和name
。我不知道为什么? here是我在小提琴上的榜样。
模板:
<div ng-controller="AppCtrl">
<table>
<tr>
<th style="width:100px;" ng-click="pred='name'">name</th>
<th style="width:100px;">id</th>
<th style="width:100px;" ng-click="pred='points'">point</th>
</tr>
<tbody ng-repeat="user in ranking | orderBy:pred">
<tr ng-repeat="tab in user.tabs | orderBy:pred">
<td style="width:100px;">{{user.name}}</td>
<td style="width:100px;">{{tab.tabId}}</td>
<td style="width:100px;">{{tab.points}}</td>
</tr>
</tbody>
</table>
</div>
控制器:
var app = angular.module('app', []);
function AppCtrl($scope) {
$scope.currentTab = 1
$scope.ranking = [
{
'uId': 2,
'name': 'Jeremy',
'tabs': [
{
'tabId': 1,
'points': 100,
},
{
'tabId': 2,
'points': 10
}
],
},
{
'uId': 3,
'name': 'Jordon',
'tabs': [
{
'tabId': 1,
'points': 180,
},
{
'tabId': 2,
'points': 5
}
],
}
]
}