I have two filters which filter the data according to the queue key in the data. Here is my code :
If you want to filter $scope.servers with the values of the queue you can try this. Hope this helps.
const servers = [
{name:'ServerA', queuearr:[{'queue' :'111'}]},
{name:'Server7', queuearr:[{'queue' :'111'}]},
{name:'Server2', queuearr:[{'queue' :'456'}]},
{name:'ServerB', queuearr:[{'queue' :'456'}]},
];
const itemsToCheck = { 'PAV':'111', 'UAT':'426' };
const filter = (arr, itemsToCheck) => arr.filter((item) => {
for (let v of Object.values(itemsToCheck)) {
const found = item.queuearr.find(({ queue }) => queue === v);
if (found) return true;
}
return false;
});
console.log(filter(servers, itemsToCheck));