Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs orderBy不适用于angular js中的嵌套数组_Angularjs_Angularjs Filter - Fatal编程技术网

Angularjs orderBy不适用于angular js中的嵌套数组

Angularjs orderBy不适用于angular js中的嵌套数组,angularjs,angularjs-filter,Angularjs,Angularjs Filter,在以下情况下,orderBy过滤器不适用于point属性和name。我不知道为什么?这是我在小提琴上的例子 模板: <div ng-controller="AppCtrl"> <table> <tr> <th style="width:100px;" ng-click="pred='name'">name</th> <th style="width:100px

在以下情况下,
orderBy
过滤器不适用于
point
属性和
name
。我不知道为什么?这是我在小提琴上的例子

模板:

<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>

您必须定义一个特定的排序函数。很好的例子[here][1][1]:您希望angular如何使用“point”进行排序?当没有任何东西被称为“点”时?这是我的拼写错误@yunandtidus,但即使它不起作用,当每个项目中有几个点时,您希望Angle如何按点排序?您需要在此处实现比较功能:
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
                }
            ],
        }
    ]
}