【问题标题】:Nativescript Angular2: Get Listview label Index or Text on TapNativescript Angular2:获取Listview标签索引或点击文本
【发布时间】:2017-04-04 23:29:40
【问题描述】:

Angular2 Nativescript Android: 我有一个列表视图,其中填充了来自 1xN 字符串数组的标签。当用户点击列表视图中的一个标签时,我想设置一个变量等于该标签的索引或标签的文本。

我应该如何修改我的 xml 和/或 selectPlan() 来做到这一点?

    <ListView [items]="submenu">
        <template let-item="item">
            <Label [text]="item" class="subUnselected" (tap)="selectPlan()"></Label>
        </template>
    </ListView>

以下是有效的:

<ListView [items]="submenu">
    <template let-item="item">
        <Label [text]="item" class="subUnselected" (tap)="selectPlan(item)"></Label>
    </template>
</ListView>


selectPlan(item) {
    var plan = item;
}

【问题讨论】:

    标签: android listview angular2-nativescript


    【解决方案1】:

    你可以把它传递给selectPlan(),所以它变成selectPlan(item)

    然后相应地调整组件中的功能。

    【讨论】:

      猜你喜欢
      • 2013-06-27
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多