How to search for a string in all properties of an object in Angular 2 with TS.
I have an array of customers rendered in a table with a search box, if the user ty
You need to apply null check and use .toString() otherwise if value will be number it will not be able to use toLowerCase() method and will raise error.
.toString()
toLowerCase()
return items.filter(item => Object.keys(item).some( k => item[k] != null && item[k] .toString() .toLowerCase() .includes(term.toLowerCase()) ) );