簡體   English   中英

結合大寫和小寫搜索選項在 angular 中不起作用

[英]Combining uppercase and lowercase search option not working in angular

在我的應用程序中,我正在嘗試搜索組合詞,例如 Solar -> S is caps and others are small letters。 在這種情況下,我的搜索過濾器選項不起作用。 僅適用於小寫字母和大寫字母。 ABCSabcd 如何為搜索選項做大寫和小寫。

過濾器.pipe.ts:

return products.filter((items) => {
  return (
    items.product_name.toLowerCase().includes(searchText) ||
    items.product_content.toLowerCase().includes(searchText) ||
    items.product_name.toUpperCase().includes(searchText) ||
    items.product_content.toUpperCase().includes(searchText)
  );
});

演示: https://stackblitz.com/edit/angular-selvam-ecommerce-task-7uau9m?file=src%2Fapp%2Fpipes%2Ffilter.pipe.ts

return products.filter((items) => {
    return (
        items.product_name.toLowerCase().includes(searchText.toLowerCase()) ||
        items.product_content.toLowerCase().includes(searchText.toLowerCase())
    );
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM