Currently, I'm working on an array of objects with the following structure.
[
{
"matListParent": "CH",
"dParent": "CUST1",
"isAllSelected": true,
"childItems": [
{
"item": "Display1",
"isSelected": true
},
{
"item": "Display2",
"isSelected": false
}
]
},
{
"matListParent": "CH2",
"dimParent": "CUST2",
"isAllSelected": true,
"childItems": [
{
"item": "Display5",
"isSelected": true
},
{
"item": "Display6",
"isSelected": false
}
]
}
]
I am attempting to retrieve the value of the item where isSelected is true. My attempt so far has been as follows:
data.filter(
(matModel: any) => matModel.matListParent === "CH").map(
(model: any) => model.childItems).map((item: any) => item).filter((list: any) => list.isSelected);
However, this code returns an empty array. What error may have occurred in my approach? Your help is greatly appreciated.
Thank you for your assistance.