Get taped item context or index in nativescript listview


#1

0
down vote
favorite

i have list of movies and i want when user does tap on the movie to change page and go to details page with this movie details.

here is my listview:

here is my itemTap function:

viewModel.itemTap = (args) => {
const navOptions={
moduleName:‘details’,
context:{
bindData:args.object.bindingContext
}
}
console.log(args.object.items)
topmost().navigate(navOptions);
}

this part args.object.items gives me full list but i dont know how to get current item which i taped… please help


Where do I start from? I'm new to NativeScript
#2

How are you using the itemTap function in your xml file?


#3

To know the tapped index use args.index / To get the tapped view reference use args.view and it’s bindingContext by args.view.bindingContext.


#4

You can refer to how to get the index of the tapped item and use it, here in the docs
https://docs.nativescript.org/cookbook/ui/list-view#itemtap-event