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

后端 未结 2 1886
轻奢々
轻奢々 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:06

    Is the attribute called 'name' or 'prdName' (the one you used in the template is 'prdName')?

    transform(values, args) {
        values.filter(
          product => product.prdName.toLowerCase().includes(args.toLowerCase())
        )
    }
    
    0 讨论(0)
  • 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());
        })
    }
    
    0 讨论(0)
提交回复
热议问题