Fixed binding expression for object property access (not function).

This commit is contained in:
Nedyalko Nikolov
2015-05-19 10:46:08 +03:00
parent 2cfaacac0e
commit e61cac3422
4 changed files with 51 additions and 27 deletions

View File

@@ -13,6 +13,7 @@ import bindingBuilder = require("ui/builder/binding-builder");
import labelModule = require("ui/label");
import textFieldModule = require("ui/text-field");
import fs = require("file-system");
import appModule = require("application");
// <snippet module="ui/core/bindable" title="bindable">
// For information and examples how to use bindings please refer to special [**Data binding**](../../../../bindings.md) topic.
@@ -513,5 +514,31 @@ export var test_BindingToSource_FailsAfterBindingContextChange = function () {
TKUnit.assertEqual(testLabel.text, expectedValue);
}
helper.buildUIAndRunTest(createLabel(), testFunc);
}
export function test_BindingToDictionaryAtAppLevel() {
var createLabel = function () {
var label = new labelModule.Label();
return label;
}
var pageViewModel = new observable.Observable();
var testPropertyName = "testValue";
var expectedValue = "expectedValue";
pageViewModel.set("testProperty", testPropertyName);
var dict = {};
dict[testPropertyName] = expectedValue;
appModule.resources["dict"] = dict;
var testFunc = function (views: Array<viewModule.View>) {
var testLabel = <labelModule.Label>(views[0]);
testLabel.bind({ sourceProperty: "testProperty", targetProperty: "text", expression: "dict[testProperty]" });
var page = <pageModule.Page>(views[1]);
page.bindingContext = pageViewModel;
TKUnit.assertEqual(testLabel.text, expectedValue);
}
helper.buildUIAndRunTest(createLabel(), testFunc);
}