kadoshms / ionic2-autocomplete

Ionic 2 autocomplete component
MIT License
149 stars 108 forks source link

More flexible data providers #76

Closed jaufgang closed 7 years ago

jaufgang commented 7 years ago

This component is helpful but it seems unnecessarily complicated to require users to create a service that implements AutoCompleteService when they may have an existing function in the parent component or another service with a name that is different from getResults.

Why not simply allow users to pass in any callback function

<ion-auto-complete [dataProvider]="mySearchFn" labelAttribute="name"></ion-auto-complete>

Where mySearchFn can be any function that accepts a string argument and returns an array?

Also, as I have in my above example, labelAttribute can be an @Input parameter of the component instead of making it a property of a service.

kadoshms commented 7 years ago

@jaufgang this is just another approach :) Do you believe that this should be a feature?

jaufgang commented 7 years ago

Yes I do. This would be much simpler to use by developers, who could then re-use existing functions in their component or other services without needing to have a special service just to use this component.

renanmoraes commented 7 years ago

How do I display more than one search result today is limited to 1, but would like to limit to 3 for example?

HugoHeneault commented 7 years ago

I agree with @renanmoraes : this service thing is a lot to implement for a quite simple thing, imo...

kadoshms commented 7 years ago

Fixed e78f12eedb0546d3dda6cd317127b84a1917aeb9