1
您好,我從顯示頻道信息的YouTube API中提取數據。下面是Ang-ng-repeat orderBy not working
channels: {
UCxxxxxxxxxxx: {
channelId: "xxxx",
channelTitle: "xxxx",
description: "xxxx",
channelId: "xxxx",
title: "xxxx"
},
UCxxxxxxxxxxx: {
channelId: "xxxx",
channelTitle: "xxxx",
description: "xxxx",
channelId: "xxxx",
title: "xxxx"
}
}
我已通過channels
對象$scope.results
我剛複製的例子從角文檔像這樣在控制器內部
$scope.predicate = 'title';
$scope.reverse = true;
$scope.order = function(predicate) {
$scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false;
$scope.predicate = predicate;
};
這裏是JSON的一個例子html標記
<table>
<thead>
<tr>
<a href="" ng-click="order('title')">Name</a>
<span class="sortorder" ng-show="predicate === 'title'" ng-class="{reverse:reverse}"></span>
</tr>
<tr>
<a href="" ng-click="order('channelTitle')">Channel</a>
<span class="sortorder" ng-show="predicate === 'channelTitle'" ng-class="{reverse:reverse}"></span>
</tr>
<tr>
<a href="" ng-click="order('viewCount')">Views</a>
<span class="sortorder" ng-show="predicate === 'viewCount'" ng-class="{reverse:reverse}"></span>
</tr>
<tr>
<a href="" ng-click="order('subscriberCount')">Subscribers</a>
<span class="sortorder" ng-show="predicate === 'subscriberCount'" ng-class="{reverse:reverse}"></span>
</tr>
</thead>
<tbody>
<tr ng-repeat="result in results | orderBy:predicate:reverse">
<td ng-bind="result.title"></td>
<td>
<a ng-show="result.channelTitle" href="https://www.youtube.com/channel/{{result.channelId}}" ng-bind="result.channelTitle"></a>
<div ng-show="!result.channelTitle" ng-bind="'--'"><div>
</td>
<td ng-bind="result.info.viewCount | number"></td>
<td ng-bind="result.info.subscriberCount | number"></td>
</tr>
</tbody>
</table>
當我點擊表頭,沒有錯誤。所以我不能確切地弄清楚什麼不起作用。任何幫助表示讚賞。謝謝。