mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 13:51:27 +08:00
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import observable = require("data/observable");
|
|
import pages = require("ui/page");
|
|
import frames = require("ui/frame");
|
|
import listView = require("ui/list-view");
|
|
|
|
import redditAppViewModel = require("./reddit-app-view-model");
|
|
|
|
var appViewModel = new redditAppViewModel.AppViewModel();
|
|
|
|
// Event handler for Page "loaded" event attached in main-page.xml
|
|
export function pageLoaded(args: observable.EventData) {
|
|
// Get the event sender
|
|
var page = <pages.Page>args.object;
|
|
|
|
page.bindingContext = appViewModel;
|
|
appViewModel.loadItemsAsync();
|
|
|
|
// Enable platform specific feature (in this case Android page caching)
|
|
if (frames.topmost().android) {
|
|
frames.topmost().android.cachePagesOnNavigate = true;
|
|
}
|
|
}
|
|
|
|
export function listViewItemTap(args: listView.ItemEventData) {
|
|
// Navigate to the details page with context set to the data item for specified index
|
|
frames.topmost().navigate({
|
|
moduleName: "./details-page",
|
|
context: appViewModel.redditItems.getItem(args.index)
|
|
});
|
|
}
|
|
|
|
export function listViewLoadMoreItems(args: observable.EventData) {
|
|
appViewModel.loadItemsAsync();
|
|
}
|