Different template for last item listview


#1

I want to add different item tamplate only for last item in listview, just a button with text add item,
is this possible? i googled it but cant find example in vanilla js


#2

Here is an example

https://docs.nativescript.org/cookbook/ui/list-view#define-multiple-item-templates-and-an-item-template-selector-in-xml


#3

I understand the xml part but, idk how to bind data to this templates, there is short code example but its typescript not a javascript, idk how to write this part in js : Array (Item)


#4

TypeScript is just JavaScript again with static typing, so removing typing is all needed to get it fit inside JS.

function selectItemTemplate(item, index, items) {
    return item.age % 2 === 0 ? "red" : "green";
}

exports.selectItemTemplate = selectItemTemplate;