Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Ionic, javascript search items in lowercase

Have a list of times, capitalized. How can i do to find them if input text is in lowercase?

ex: Barcelona, when input "bar", find it. Try with .lowercase() but doesn’t works

onSearch(text){
    if(text){
      const filter_data=this.old_locations.filter((element) => element.title.includes(text));
      this.locations=filter_data;
    }else{
      this.locations=this.old_locations;
    }
  }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

How about this

this.locations = text ? this.old_locations
  .filter(element => element.title.toLowerCase().includes(text.toLowerCase())) :
  this.old_locations;

Save some cycles by lowercasing text first

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading