I have an array of multiple objects that is mocked and want to filter based on t_name_food.
this.lista_categoria_food = [
{
n_id: 1,
t_nome_categorie: 'Main Dishes',
t_image: 'Service.jpg',
list_food: [
{ n_id: 1,
t_name_food: 'dish 1 ',
t_price_food: 20,
n_quantity: 0,
t_quantity: 'piece' },
{ n_id: 2,
t_name_food: 'dish 2',
t_price_food: 20,
n_quantity: 0,
t_quantity: 'piece' },
]
},
{
n_id: 2,
t_nome_categorie: 'Appetizers',
t_image: 'restaurant.jpg',
list_food: [
{ n_id: 1,
t_name_food: 'food 1',
t_price_food: 20,
n_quantity: 0,
t_quantity: 'piece' },
{ n_id: 2,
t_name_food: 'food 2',
t_price_food: 20,
n_quantity: 0,
t_quantity: 'piece' },
]
},
]
The filter should retrun the list of products that match in t_name_food.
Until now have tried to filter items of object.
this.lista_categoria_food = this.filterFeeds.forEach((item) => {
item.list_food.filter(e =>
{
if(e.t_name_food.toLowerCase().includes(searchTerm.toLowerCase())) {
return e;
} }) },
);