在NativeScript ListView中忽略nsTemplateKey
我试图在ListView中使用两个模板,但是ListView总是选择第一个模板。回调函数返回模板键的正确值无效 标记:在NativeScript ListView中忽略nsTemplateKey,listview,nativescript,angular2-nativescript,Listview,Nativescript,Angular2 Nativescript,我试图在ListView中使用两个模板,但是ListView总是选择第一个模板。回调函数返回模板键的正确值无效 标记: <ListView row="0" [items]="eventRoll.people" (itemTap)="onItemTap($event)" [itemTemplateSelector]="templateSelector"> <template nsTemplateKey="absent" let-item="item"> &l
<ListView row="0" [items]="eventRoll.people" (itemTap)="onItemTap($event)"
[itemTemplateSelector]="templateSelector">
<template nsTemplateKey="absent" let-item="item">
<Label style="background-color:lightblue" [text]="item.isAccounted ? 'here' : 'absent'"></Label>
</template>
<template nsTemplateKey="here" let-item="item">
<Label style="background-color:lightgreen" [text]="item.isAccounted ? 'here' : 'absent'"></Label>
</template>
</ListView>
我简化了标记,因此唯一的区别是背景颜色。无论nsTemplateKey是什么,都将使用第一个模板
我错过了什么?为什么不根据键使用模板?如果这是角度4,则
模板
应为ng模板
。我看不到任何明显的东西。谢谢@EddyVerbrugen!修正它的是更新框架和使用你提到的ng模板!
public templateSelector = (item: Person, index: number, items: any) => {
let key = item.isAccounted ? "here" : "absent";
return key;
}