diff --git a/apps/tests/ui/bindable-tests.ts b/apps/tests/ui/bindable-tests.ts index ceaf16135..66c6ca4a9 100644 --- a/apps/tests/ui/bindable-tests.ts +++ b/apps/tests/ui/bindable-tests.ts @@ -963,3 +963,28 @@ export function test_SupportFunctionsInExpressions() { TKUnit.assertEqual(bindableObj.get("test"), "visible", "When anyColor is red test property should be visible."); } + +export function test_$ValueSupportWithinExpression() { + var model = new observable.Observable({ + "anyColor": "red", + "isVisible": function () { + return this.get("anyColor") === "red"; + } + }); + + var bindableObj = new bindable.Bindable(); + + bindableObj.bind({ + "sourceProperty": "$value", + "targetProperty": "test", + "expression": "$value.anyColor === 'red' ? 'red' : 'blue'" + }, model); + + model.set("anyColor", "blue"); + + TKUnit.assertEqual(bindableObj.get("test"), "blue", "When anyColor is blue test property should be blue too."); + + model.set("anyColor", "red"); + + TKUnit.assertEqual(bindableObj.get("test"), "red", "When anyColor is red test property should be red too."); +} \ No newline at end of file diff --git a/ui/core/bindable.ts b/ui/core/bindable.ts index 06ede876f..3eb0975f5 100644 --- a/ui/core/bindable.ts +++ b/ui/core/bindable.ts @@ -458,6 +458,9 @@ export class Binding { private prepareContextForExpression(model, expression) { var parentViewAndIndex; var parentView; + if (expression.indexOf(bc.bindingValueKey) > -1) { + model[bc.bindingValueKey] = model; + } if (expression.indexOf(bc.parentValueKey) > -1) { parentView = this.getParentView(this.target.get(), bc.parentValueKey).view; if (parentView) {