Angular, TypeError: Cannot read property 'toLowerCase' of undefined

后端 未结 2 1899
轻奢々
轻奢々 2020-12-19 18:50

i\'m trying to make a custom filter pipe by following this link, but i got error that said Angular, TypeError: Cannot read property \'toLowerCase\' of undefined

2条回答
  •  天涯浪人
    2020-12-19 19:16

    try like this :

    transform(items: any, term: any): any {
        if (term === undefined) return items;
    
        return items.filter(function(Product) {
            return Product.prdName.toLowerCase().includes(term.toLowerCase());
        })
    }
    

提交回复
热议问题