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.
Demo: https://stackblitz.com/edit/angular-selvam-ecommerce-task-mffqdn?file=src/app/pipes/filter.pipe.ts
CodePudding user response:
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.