mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00

* fix(list-view): app crashes on first ListView item template change * tests: add tests for changing ListView item template with expression
21 lines
563 B
TypeScript
21 lines
563 B
TypeScript
import { Page } from "tns-core-modules/ui/page";
|
|
import { ViewModel } from "./main-view-model";
|
|
|
|
export function pageLoaded(args) {
|
|
let page = <Page>args.object;
|
|
const viewModel = new ViewModel();
|
|
|
|
page.bindingContext = {
|
|
"items": viewModel.items
|
|
}
|
|
}
|
|
|
|
exports.onItemTap = function (args) {
|
|
const list = args.object;
|
|
let index = args.index;
|
|
let listArray = list.page.bindingContext["items"];
|
|
let currentItem = listArray.getItem(index);
|
|
|
|
currentItem.age = currentItem.age + 1;
|
|
listArray.setItem(index, currentItem);
|
|
} |