PeterStaev / NativeScript-Drop-Down

A NativeScript DropDown widget.
Apache License 2.0
105 stars 65 forks source link

Accessing selected value instead of selected index #208

Open kamilchlebek opened 5 years ago

kamilchlebek commented 5 years ago

I'm using DropDown in angular application. I've successfully provided values using ValueList. Then I've created ReactiveForm and attached formControlName to DropDown component. Unfortunately form is updated with selected index instead of selected value.

I've seen few tasks regarding this issue. Nevertheless maybe it would be good to provide users with some configuration to change that behavior? Some libraries provide bindLabel and bindValue options.

It's especially inconvenient when you provide items using async pipe: [items]="items$ | async, because to fetch selected value you have to create another combination of Observables and operators to fetch value for given index.

PeterStaev commented 5 years ago

Hey @kamilchlebek , thank you for the suggestion. Sadly for the time being I do not plan on adding this. If you look at the ListPicker widget from NativeScript it follows the same concept. If you want the value you can simply handle the selectedIndexChanged and update your value. Or if you need it only for save, you can pull the value by its index before sending the data to your backend.

kamilchlebek commented 5 years ago

Thanks for your response. I handle it on my side. I just wanted to share the suggestion with you :)