Fixed adding converters to bindingContext.

This commit is contained in:
Nedyalko Nikolov
2016-04-20 15:49:44 +03:00
parent c7918c51ce
commit 8fef852d89
2 changed files with 13 additions and 3 deletions

View File

@ -567,6 +567,7 @@ export function test_BindingToDictionaryAtAppLevel() {
page.bindingContext = pageViewModel;
TKUnit.assertEqual(testLabel.text, expectedValue);
TKUnit.assertTrue(testLabel.bindingContext["dict"] === undefined, "BindingContext should not contain properties from application resources.");
}
helper.buildUIAndRunTest(createLabel(), testFunc);

View File

@ -386,17 +386,26 @@ export class Binding {
if (exp) {
var context = this.source && this.source.get && this.source.get() || global;
var model = {};
var addedProps = [];
ensureApplication();
for (var prop in application.resources) {
if (application.resources.hasOwnProperty(prop) && !context.hasOwnProperty(prop)) {
context[prop] = application.resources[prop];
addedProps.push(prop);
}
}
this.prepareContextForExpression(context, expression);
model[contextKey] = context;
return exp.getValue(model, isBackConvert, changedModel ? changedModel : model);
let result = exp.getValue(model, isBackConvert, changedModel ? changedModel : model);
// clear added props
let addedPropsLength = addedProps.length;
for(let i = 0; i < addedPropsLength; i++) {
delete context[addedProps[i]];
}
addedProps.length = 0;
return result;
}
return new Error(expression + " is not a valid expression.");
}