XML
var observableModule = require("data/observable");
var source = new observableModule.Observable();
var HomePage = function() {};
HomePage.prototype = new BasePage();
HomePage.prototype.constructor = HomePage;
HomePage.prototype.contentLoaded = function(args) {
var page = args.object;
source.textSource = "sample";
var layout = page.getViewById("stackID");
var textField = new TextFieldModule.TextField();
var textFieldBindingOptions = {
sourceProperty: "textSource",
targetProperty: "text",
twoWay: false
};
textField.bind(textFieldBindingOptions, source);
layout.addChild(textField);
}
HomePage.prototype.buttonTap = function() {
source.textSource = "new word";
source.update();
}
の後ろに私は、クリックでソースを更新する方法で見つけることができました。
HomePage.prototype.onTap = function() {
source.set("textSource", "new word");
}
出典:http://docs.nativescript.org/cookbook/data/observable