Reputation: 15
I have one search box in my angular application. Search result should be return two object values like product_name and product_content.But in my application it is taking only one object.But i want to apply search option for both like product_name and product_content.
filter.pipe.ts:
return products.filter((items) => {
return (
items.product_name.toLowerCase().includes(searchText), // Not working
items.product_content.toLowerCase().includes(searchText) // working
);
});
So, How to resolve this issue? If anyone knows help to find the solution.
Upvotes: 0
Views: 414
Reputation: 479
return products.filter((items) => {
return (
items.product_name.toLowerCase().includes(searchText.toLowerCase()) ||
items.product_content.toLowerCase().includes(searchText.toLowerCase())
);
});
Instead of ,
put an ||
to check both conditions.
Upvotes: 1