From bf79bd4194eca2118ae1c492c08dbd217f5ae810 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 20 Aug 2013 16:08:24 -0700 Subject: fix(ngTransclude): make the transclusion available to parent post-link previously the translusion was appended the the ngTranslude element via $evalAsync which makes the transluded dom unavailable to parent post-linking functions. By appending translusion in linking phase, post-linking functions will be able to access it. --- src/ng/directive/ngTransclude.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/ng/directive/ngTransclude.js') diff --git a/src/ng/directive/ngTransclude.js b/src/ng/directive/ngTransclude.js index 668f8033..0b9b919d 100644 --- a/src/ng/directive/ngTransclude.js +++ b/src/ng/directive/ngTransclude.js @@ -49,14 +49,16 @@ * */ var ngTranscludeDirective = ngDirective({ - controller: ['$transclude', '$element', '$scope', function($transclude, $element, $scope) { - // use evalAsync so that we don't process transclusion before directives on the parent element even when the - // transclusion replaces the current element. (we can't use priority here because that applies only to compile fns - // and not controllers - $scope.$evalAsync(function() { - $transclude(function(clone) { - $element.append(clone); - }); + controller: ['$transclude', function($transclude) { + // remember the transclusion fn but call it during linking so that we don't process transclusion before directives on + // the parent element even when the transclusion replaces the current element. (we can't use priority here because + // that applies only to compile fns and not controllers + this.$transclude = $transclude; + }], + + link: function($scope, $element, $attrs, controller) { + controller.$transclude(function(clone) { + $element.append(clone); }); - }] + } }); -- cgit v1.2.3