mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
34 lines
887 B
TypeScript
34 lines
887 B
TypeScript
import observableModule = require("data/observable");
|
|
import pageModule = require("ui/page");
|
|
|
|
class MainViewModel extends observableModule.Observable {
|
|
private _item: any;
|
|
|
|
constructor() {
|
|
super();
|
|
|
|
this.item = { Title: "Alabala" };
|
|
}
|
|
|
|
get item(): any {
|
|
return this._item;
|
|
}
|
|
|
|
set item(value: any) {
|
|
if (this._item !== value) {
|
|
this._item = value;
|
|
this.notifyPropertyChanged("item", value);
|
|
}
|
|
}
|
|
|
|
notifyPropertyChanged(propertyName: string, value: any) {
|
|
this.notify({ object: this, eventName: observableModule.Observable.propertyChangeEvent, propertyName: propertyName, value: value });
|
|
}
|
|
}
|
|
|
|
var viewModel = new MainViewModel();
|
|
|
|
export function pageLoaded(args: observableModule.EventData) {
|
|
var page = <pageModule.Page>args.object;
|
|
page.bindingContext = viewModel;
|
|
} |