From 90f87072e83234ae366cfeb3c281503c31dad738 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Thu, 14 Nov 2013 13:50:36 -0800 Subject: fix($compile): accessing controllers of transcluded directives from children Additional API (backwards compatible) - Injects `$transclude` (see directive controllers) as 5th argument to directive link functions. - `$transclude` takes an optional scope as first parameter that overrides the bound scope. Deprecations: - `transclude` parameter of directive compile functions (use the new parameter for link functions instead). Refactorings: - Don't use comment node to temporarily store controllers - `ngIf`, `ngRepeat`, ... now all use `$transclude` Closes #4935. --- src/ngRoute/directive/ngView.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/ngRoute/directive/ngView.js') diff --git a/src/ngRoute/directive/ngView.js b/src/ngRoute/directive/ngView.js index a8a136df..3271ac0c 100644 --- a/src/ngRoute/directive/ngView.js +++ b/src/ngRoute/directive/ngView.js @@ -173,8 +173,7 @@ function ngViewFactory( $route, $anchorScroll, $compile, $controller, terminal: true, priority: 400, transclude: 'element', - compile: function(element, attr, linker) { - return function(scope, $element, attr) { + link: function(scope, $element, attr, ctrl, $transclude) { var currentScope, currentElement, autoScrollExp = attr.autoscroll, @@ -200,7 +199,7 @@ function ngViewFactory( $route, $anchorScroll, $compile, $controller, if (template) { var newScope = scope.$new(); - linker(newScope, function(clone) { + $transclude(newScope, function(clone) { clone.html(template); $animate.enter(clone, null, currentElement || $element, function onNgViewEnter () { if (angular.isDefined(autoScrollExp) @@ -235,7 +234,6 @@ function ngViewFactory( $route, $anchorScroll, $compile, $controller, cleanupLastView(); } } - }; } }; } -- cgit v1.2.3