guylabs / ion-autocomplete

A configurable Ionic directive for an autocomplete dropdown
MIT License
264 stars 88 forks source link

issue with the "component-id" #227

Open jperruchas opened 7 years ago

jperruchas commented 7 years ago

Hello, First, thank you for your plugin, it's very useful and easy to use. However I have an issue about the component-id. I have a javascript object which contains severals keys and values. I generate the ion-complete widgets into a ng-repeat based on this object, so I have several ion-complete widgets and I wanted to add an parameter to know which is called by the callback method. I setup the component-id like this component-id="{{oneHosp[cle]}}". "cle" is the value from the ng-repeat. When I check the generated HTML template, I can see component-id="1096". But, in the callback method, the console.log on the component-id, instead of 1096, it shows {{oneHosp[cle]}}, why ? Thank you

guylabs commented 7 years ago

Hi @jperruchas

well the problem here is that the component-id is used as standard attribute and is not parsed like some other attributes. See https://github.com/guylabs/ion-autocomplete/blob/master/src/ion-autocomplete.js#L48 how it is done currently.

You can come up with a PR to change this to a one way binded attribute like for example the placeholder (see https://github.com/guylabs/ion-autocomplete/blob/master/src/ion-autocomplete.js#L18) Then add some tests for it, but you can copy nearly everything how it is done with the placeholder.

Currently I do not have the time to work on the component and a PR would be really appreciated.

Thanks and regards

Guy