When I am try to integrate autocomplete in angular2, I got TypeError i.e
el.toLowerCase is not a function.
filter() {
if (this.query !== ""){
this.filteredList = this.names.filter(function(el){
return el.toLowerCase().indexOf(this.query.toLowerCase()) > -1;
}.bind(this));
}else{
this.filteredList = [];
}
}
Try return el.toString().toLowerCase().indexOf(this.query.toLowerCase()) > -1;
. If the argument el
is not a string, the toLowerCase()
function won't work on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With