I am trying to use search bar component but ı got this error
Cannot read property 'toLowerCase' of null
These are my codes
getItems(ev: any) {
// Reset items back to all of the items
this.initializeItems();
// set val to the value of the searchbar
let val = ev.target.value;
this.contac.forEach(element => {
console.log("element",element.displayName.toLowerCase())
});
// if the value is an empty string don't filter the items
if (val && val.trim() != '') {
this.contac = this.contac.filter((item) => {
return (item["displayName"].toLowerCase().indexOf(val.toLowerCase()) > -1);
})
}
}
I checked item[“displayName”] weather it s null or not .It s not null
Any suggestion
Thanks in Advance