过滤器angularjs不'对我来说不起作用

filter angularjs doesn't work in my case

本文关键字:对我来说 不起作用 angularjs 过滤器      更新时间:2023-09-26

我将其添加到<li>(第5行)中,但返回为空。

| filter: {tabs.tabId: currentTab}

我的应用程序演示http://jsfiddle.net/8Ub6n/8/

我的html

 <ul ng-repeat="friend in user">
            <li ng-repeat="relation in friend.relationship">{{relation.name}} ({{relation.points}}points)</li>
        </ul>

这是我的js

 $scope.user = [{
        'uId': 1,
            'name': 'Joe',
            'relationship': [{
            'uId': 2,
                'name': 'Jeremy',
                'tabs': [{
                'tabId': 1
            }],
                'tasks': [{
                'name': 'Im Jeremy Lin'
            }],
                'points': 50
        },{
            'uId': 2,
                'name': 'Michael',
                'tabs': [{
                'tabId': 1
            }],
                'tasks': [{
                'name': 'Im Jeremy Lin'
            }],
                'points': 80
        }]
    }]
})

不知道怎么了。。

完成:

这是

只需要在范围内制作另一个功能:

$scope.isTab = function (relation) {
   return relation.tab.tabId == $scope.currentTab;
}

然后添加到过滤器:

relation in friend.relationship | filter : isTab