From fca036f3103298c593121cc5d7c3e7be5327566e Mon Sep 17 00:00:00 2001 From: aoancea Date: Sun, 13 Sep 2015 19:50:21 +0300 Subject: [PATCH 1/2] - new directive operator for one-way object binding in directive --- src/ng/compile.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/ng/compile.js b/src/ng/compile.js index 20eb7593d776..865571750f60 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -2663,6 +2663,31 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { return parentGet(scope, locals); }; break; + + case '#': + parentGet = attrs.hasOwnProperty(attrName) ? $parse(attrs[attrName]) : noop; + + if (parentGet === noop && optional) break; + + var parentValue = parentGet(scope); + + if (!isObject(parentValue)) + throw $compileMinErr('nonassign', + "Attribute value has to be an object in directive '{0}'." + + " Definition: {... {1}: '{2}' ...}", + directive.name, scopeName, definition); + + destination[scopeName] = copy(parentValue); + + var unwatch; + unwatch = scope.$watch(function parentValueWatch() { + return $parse(attrs[attrName])(scope); + }, function onParentValueChange(newParentValue) { + destination[scopeName] = copy(newParentValue); + }); + onNewScopeDestroyed = (onNewScopeDestroyed || []); + onNewScopeDestroyed.push(unwatch); + break; } }); var destroyBindings = onNewScopeDestroyed ? function destroyBindings() { From 4c68c871ed3a49234b73443a0689222132b47441 Mon Sep 17 00:00:00 2001 From: aoancea Date: Sun, 13 Sep 2015 19:59:55 +0300 Subject: [PATCH 2/2] - directive operator added in LOCAL_REGEXP --- src/ng/compile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 865571750f60..b0420ad99d9c 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -757,7 +757,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; function parseIsolateBindings(scope, directiveName, isController) { - var LOCAL_REGEXP = /^\s*([@&]|=(\*?))(\??)\s*(\w*)\s*$/; + var LOCAL_REGEXP = /^\s*([@&#]|=(\*?))(\??)\s*(\w*)\s*$/; var bindings = {};