检查资源的id是否在ng-repeat中显示的另一个资源的id列表中

时间:2015-03-19 12:50:45

标签: javascript angularjs

我有资源

$scope.list = [
             { listId:1, name: "Test1" }, 
             { listId:2, name: "Test 2" }
              ];

我还有一个引用第一个listId

的资源
$scope.includedList = [
           {
             includedListId:1, 
             title: "Title 1",
             listId:1 
           }];

我有一个带有重复的显示,我想检查列表项是否包含在第二个资源中。

< a ng-repeat="item in list" 
    ng-class="selected if item is included in includedList"
>

1 个答案:

答案 0 :(得分:0)

写一个函数

$scope.isIncluded = function ()

然后

  

&LT; a ng-repeat =“列表中的项目”ng-class =“{selected:isIncluded(item,includedList)}”&gt;

我不明白包含的确切逻辑,所以我将函数留空