diff options
| author | Igor Minar | 2012-05-02 21:08:02 -0700 | 
|---|---|---|
| committer | Igor Minar | 2012-05-03 00:15:26 -0700 | 
| commit | 705f4bbf115d2408e33b25f56edbf1f383aabb82 (patch) | |
| tree | 63e34d7405929c81aa4cb7104d2c468bfc4b559e /src/ng/compile.js | |
| parent | bd530e225750e9b30b6300fc3d7447a5f1071667 (diff) | |
| download | angular.js-705f4bbf115d2408e33b25f56edbf1f383aabb82.tar.bz2 | |
fix($compile): attach scope to the directive element when templateUrl and replace=true
We forgot to reattach the scope to the replacement element. This affected only
directives that had templateUrl and replace:true properties.
Reported on the mailing list:
https://groups.google.com/forum/?fromgroups#!topic/angular/zwjLr1msS2Y
http://jsfiddle.net/lukebayes/g9Sh9/
Diffstat (limited to 'src/ng/compile.js')
| -rw-r--r-- | src/ng/compile.js | 13 | 
1 files changed, 12 insertions, 1 deletions
| diff --git a/src/ng/compile.js b/src/ng/compile.js index 17f49d68..61e88df6 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -852,13 +852,24 @@ function $CompileProvider($provide) {                  linkRootElement = linkQueue.pop(),                  cLinkNode = linkQueue.pop(),                  scope = linkQueue.pop(), -                node = templateNode; +                node = templateNode, +                cLinkNodeJq = jqLite(cLinkNode);              if (cLinkNode !== originalWidgetNode) {                // it was cloned therefore we have to clone as well.                node = JQLiteClone(templateNode);                replaceWith(linkRootElement, jqLite(cLinkNode), node);              } + +            if (replace) { +              if (cLinkNodeJq.data('$scope')) { +                // if the original element before replacement had a new scope, the replacement should +                // get it as well +                jqLite(node).data('$scope', scope); +              } +              dealoc(cLinkNodeJq); +            } +              afterWidgetLinkFn(function() {                beforeWidgetLinkFn(afterWidgetChildrenLinkFn, scope, node, rootElement, controller);              }, scope, node, rootElement, controller); | 
