Javascript 通过不工作来重复命令

Javascript 通过不工作来重复命令,javascript,angularjs,youtube-api,youtube-data-api,Javascript,Angularjs,Youtube Api,Youtube Data Api,嗨,我从显示频道信息的YouTube api中提取了数据。下面是一个JSON示例 channels: { UCxxxxxxxxxxx: { channelId: "xxxx", channelTitle: "xxxx", description: "xxxx", channelId: "xxxx", title: "xxxx" }, UCxxxxxxxxxxx: { chann

嗨,我从显示频道信息的YouTube api中提取了数据。下面是一个JSON示例

channels: {
    UCxxxxxxxxxxx: {
        channelId: "xxxx",
        channelTitle: "xxxx",
        description: "xxxx",
        channelId: "xxxx",
        title: "xxxx"
    },
    UCxxxxxxxxxxx: {
        channelId: "xxxx",
        channelTitle: "xxxx",
        description: "xxxx",
        channelId: "xxxx",
        title: "xxxx"
    }
}
我已将
通道
对象传递给
$scope.results

我只是从控制器内部的角度文档复制了这个例子

    $scope.predicate = 'title';
    $scope.reverse = true;
    $scope.order = function(predicate) {
        $scope.reverse = ($scope.predicate === predicate) ? !$scope.reverse : false;
        $scope.predicate = predicate;
    };
这是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>

单击表格标题时,没有错误。所以我不能确切地找出什么不起作用。感谢您的帮助。谢谢。

您的对象(在ng repeat中使用)与原始示例()不同

结果必须是数组。 原始数据:

$scope.friends =
          [{name:'John', phone:'555-1212', age:10},
           {name:'Mary', phone:'555-9876', age:19},
           {name:'Mike', phone:'555-4321', age:21},
           {name:'Adam', phone:'555-5678', age:35},
           {name:'Julie', phone:'555-8765', age:29}];
$scope.friends =
          [{name:'John', phone:'555-1212', age:10},
           {name:'Mary', phone:'555-9876', age:19},
           {name:'Mike', phone:'555-4321', age:21},
           {name:'Adam', phone:'555-5678', age:35},
           {name:'Julie', phone:'555-8765', age:29}];