我正在尝试检查评估具有多个对象的每个 ng-repeat 列表数组。 有办法实现这一点吗?
请查找以下代码供您引用。
**<div ng-repeat="i in items" ng-show="items.id === arrayList[]" />
$scope.arrayList = [{"id":"1"},{"id":"2"},...]**
我需要检查 items.id 是否与任何 arraylist object.id 匹配。任何人都可以帮助我吗?
items 中的 i 来自 api 服务
最佳答案
在 Controller 中编写一些函数,例如这样。
$scope.isMatch = function(id) {
for(var i =0; i < arrayList.length; i ++){
if(arrayList[i].id === id){
return true;
}
}
return false;
}
然后在 View 中使用它。
ng-show="isMatch(i.id)"
关于javascript - 如何检查 ng-show={{}} 表达式与值数组列表是否匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37554180/