Reputation: 5126
I'm using NativeScript 6.1.1 and I have a RadListView in which I would like to have unique references for each row. One way I was thinking of is if I could get an index field then I could have the 'automationText' fields with the following
name0
name1
name2
Here is my current template;
<RadListView automationText="listing"
[items]="dataItems"
[filteringFunction]="filterItems"
pullToRefresh="true"
(pullToRefreshInitiated)="onPullToRefreshInitiated($event)">
<ng-template tkListItemTemplate let-item="item">
<StackLayout orientation="vertical">
<GridLayout class="itemContainer" rows="50,*" columns="*,100">
<Label automationText="name" row="0" col="0" class="nameLabel" [text]="item.name"></Label>
</GridLayout>
</StackLayout>
</ng-template>
</RadListView>
Is it possible to do something like this?
<Label automationText="name#{index}" row="0" col="0" class="nameLabel" [text]="item.name"></Label>
Upvotes: 1
Views: 664
Reputation: 855
to get the index you may add let-i="index"
to ng-template and consume it as automationText="name{{i}}"
sample:
<RadListView [items]="_dataItems" [itemTemplateSelector]="templateSelector">
<ng-template tkTemplateKey tkListItemTemplate let-item="item"
let-i="index">
<StackLayout>
<Label automationText="name{{i}}" text="name{{i}}"></Label>
</StackLayout>
</ng-template>
</RadListView>
Upvotes: 2