In NativeScript with Angular2 get element value

前端 未结 1 797
名媛妹妹
名媛妹妹 2021-01-26 13:40

I have a list, and I want to get the value of the list item.

The view is as follows

         


        
1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-26 14:26

    You can access the view of your item template via args.view. From that point, I assume that you will have different text in your list-items so it is important to create unique IDs for each Label via binding(using the Angular index). So you can do the following:

    
        
    
    

    and then in your onItemTap

    public onItemTap(args: ItemEventData) {
        console.log("Item Tapped at cell index: " + args.index);
        console.log(args.object); // prints something like ListView(137)
        console.log(args.view); // prints something like StackLayout(265)
    
        var lbl = 

    0 讨论(0)
提交回复
热议问题