I am trying to create a custom angular filter based on an array of strings, for example:
$scope.idArray = ['1195986','1195987','1195988']
The data I want to filter is in the format:
$scope.data = {
"moduleName": null,
"contentholder_0": {
"moduleName": "contentholder",
"id": "-1",
"name": "",
"content": ""
},
"webapps_1": {
"moduleName": "webapps",
"items": [{
"itemid": "1195986",
"name": "abc"
},{
"itemid": "1195987",
"name": "def"
},{
"itemid": "1195988",
"name": "ghi"
}]
}
}
I have looked at this Stack Question to try to create a custom filter: Example
Here is the JSFiddle of the answer
I have not been able to hack it to fit my data structure for what I want to do (filter the "items" if the "itemid" is in the "idArray")
This is a JSfiddle as close as I can get without crashing angular.
Please forgive me if this is a super easy question but I am a beginner and have tried multiple ways to get this to work but haven't been able to. I am not sure where the actual filtering is being done and how to compare the strings in idArray to data.webapps_1.items.itemid
Any help would be greatly appreciated.