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

check if the id of a resource is in the id list of another resource displayed in a ng-repeat

本文关键字:id 资源 显示 另一个 列表 ng 是否 检查      更新时间:2023-09-26

我有一个资源

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

我还有另一个资源引用了第一个具有listId 的资源

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

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

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

编写一个函数

$scope.isIncluded = function ()

然后

<a ng repeat="列表中的项目"ng class="{selected:isIncluded(item,includedList)}">

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