I’m reading in a json file into an object, which is being used by a ion-list to display the data. I want to be able to search the data, but I’m having problems.
I see multiple examples of filtering an array (which works fine) but I need a more complicated object.
This is the json
{
"menuItems": [ {
"id": "1",
"name": "Protocols",
"itemPage": "protocols",
"icon": "bookmarks"
},
{
"id": "2",
"name": "Hospitals",
"itemPage": "hospitals",
"icon": "compass"
},
{
"id": "3",
"name": "Medications",
"itemPage": "meds",
"icon": "medkit"
},
{
"id": "4",
"name": "Calculators",
"itemPage": "calcs",
"icon": "calculator"
},
{
"id": "5",
"name": "Burn Tools",
"itemPage": "burntools",
"icon": "bonfire"
},
{
"id": "6",
"name": "References",
"itemPage": "references",
"icon": "book"
},
{
"id": "7",
"name": "Medical Command",
"itemPage": "medcomm",
"icon": "logo-whatsapp"
}
]
}
So the object returned should be able to be accessed like:
results.id
results.name
etc.
I want to be able to pass a search string and only return the items that contain that search string but darn if I can find any working examples to help me along.
Can anyone help?