Nativescript version of the html select



I found this :

but it doesn’t seem to work like the html select where I can have a value and text.

How would I do this in Nativescript?




I’ve been binding an array to my list pickers and then using the selectedIndex property to get that value of the array.

something like:

let values = ['option 1', 'option 2', 'option 3']
listpicker = page.getViewById('MyListPicker');

let selectedValue = values[listpicker.selectedIndex];


That makes a lot of sense. Thank You.


How can I get the tap event when the user selects an item. ??



Sir, any solution !!

I am able to get the index and item but.
when he scrolls the listpicker i want that item to be displayed in a label on same view.


With an onItemTap listener on the listview, when you tap on a list item, the listener will be called, and as a parameter you will be able to retrieve the index of the item tapped. Then you can get the item by index from the array that you’ve initially bound to the listview, and display its information any way you like.

Not sure if I am making much sense, it’s early in the morning.


hahhaa :smiley: Happy Morning sir,

thanks a lot for the response. I will give get back here once I give it a try.

Have a great day.