Added binding convert option.

This commit is contained in:
Nedyalko Nikolov
2015-03-04 09:57:04 +02:00
parent cc829e0152
commit 8bc83ced24
9 changed files with 196 additions and 39 deletions

View File

@@ -77,7 +77,7 @@ export function getComponentModule(elementName: string, namespace: string, attri
// Get the event handler from instance.bindingContext.
var propertyChangeHandler = (args: observable.PropertyChangeData) => {
if (args.propertyName === "bindingContext") {
var handler = instance.bindingContext && instance.bindingContext[getPropertyNameFromBinding(attrValue)];
var handler = instance.bindingContext && instance.bindingContext[getBindingExpressionFromAttribute(attrValue)];
// Check if the handler is function and add it to the instance for specified event name.
if (types.isFunction(handler)) {
instance.on(attr, handler, instance.bindingContext);
@@ -157,10 +157,10 @@ function isKnownEvent(name: string, exports: any): boolean {
}
function getBinding(instance: view.View, name: string, value: string): bindable.BindingOptions {
return { targetProperty: name, sourceProperty: getPropertyNameFromBinding(value), twoWay: true };
return bindable.Bindable._getBindingOptions(name, getBindingExpressionFromAttribute(value));
}
function getPropertyNameFromBinding(value: string): string {
function getBindingExpressionFromAttribute(value: string): string {
return value.replace("{{", "").replace("}}", "").trim();
}