oferh / ng2-completer

Angular 2 autocomplete component
http://oferh.github.io/ng2-completer/
MIT License
347 stars 172 forks source link

Case insensitive #353

Open puntapret opened 6 years ago

puntapret commented 6 years ago

Hi,

I'm using your example of completer-cmp-md-html to create a custom style, and the search in ng-completer is case sensitive, and in your examples all the search are case insensitive. Is there an option to make the search case insensitive ? I can't seem to find that option.

It should return the same result when typing CFC or cfc.

I use the local data with a custom object : this.dataService = this.completerService.local(totalResult, 'Name', 'Name').descriptionField("CriteriaString").imageField("IconClass");

And everytime the user type a keyword, i set another data service. It seems this cause the problem. If i didn't set a new one, it's working. Thank you

oferh commented 6 years ago

Hi,

you shouldn't create a different data service every time, you should pass the results as observable see this plunker for an example.

puntapret commented 6 years ago

Thank you oferh.

I wish it could be that simple. The data comes from multiple web services. And it returns hundreds of results. And from each web service result i tried to pick multiple results basing on some logics, and it was done on client side. That’s why i keep creating a different data service. Everytime user type a character, the logic will try to pick some results from each web services, and it can be very different. I don’t know if this can be done differently, but changing data service is the way i can see it.

oferh commented 6 years ago

@puntapret you can create a Subject use it as the data for this.completerService.local() and each time you have a new set of items just call mySubject.next(items)

oferh commented 6 years ago

b.t.w change of the data source is supported

puntapret commented 6 years ago

Thank you. I’ll try it later.

And i also have a drop down list that can also narrow down the criteria on the search. Is it possible to force the completer list to refresh ?

Let me explain :

The user type toto in the search input form, and then finally he decide to select a criteria from drop down list, he choose criteria A. On the code behind i will create the new data service and force the completer drop down to open again but with the new result. Somehow the list are not refreshed, the only way to refresh is i force the search string to become Toto (notice the capital). If i force the change in the input search form the list is refreshed.

Any idea in how this can be done ?

Thanks