diff --git a/src/ng/compile.js b/src/ng/compile.js index 20eb7593d776..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 = {}; @@ -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() {