forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbindingContext_testPage.ts
More file actions
34 lines (26 loc) · 887 Bytes
/
bindingContext_testPage.ts
File metadata and controls
34 lines (26 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
}