我要检查是否存在重复的output
数组对象outputTypeId
数组检查重复..中包含的对象作为数组
下面是JSON:
$scope.entities= [
{
"input": {
"id": 134
},
"output": [
{
"id": 135,
"outputTypeId": 4
}
]
},
{
"input": {
"id": 134
},
"output": [
{
"id": 135,
"outputTypeId": 7
}
]
},
{
"input": {
"id": 134
},
"output": [
{
"id": 135,
"outputTypeId": 9
}
]
}
]
下面是代码我试过但它没有在执行后的条件下..
让我[7]我检查多个outputTypeId的,因此一个数组
$scope.checkForDuplicateOutputs = (outputTypeId) => {
for (var i = 0; i < $scope.entities.length; i++) {
for (var j = i; j < $scope.entities[i].output[j].length; j++) {
if (outputTypeId.contains($scope.entities[i].output[j].outputTypeId)) {
$scope.isDuplicateOutput = true;
break;
} else {
$scope.isDuplicateOutput = false;
}
}
}
}
尝试grep将帮助 –