From 45f9f62367221b2aa097ba1d87d744e50140ddc7 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 18 Jul 2013 11:30:32 -0700 Subject: fix($compile): always instantiate controllers in parent->child order Previously it was possible to get into a situation where child controller was being instantiated before parent which resulted in an error. Closes #2738 --- src/ng/directive/ngTransclude.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ng/directive/ngTransclude.js b/src/ng/directive/ngTransclude.js index c15b77cb..668f8033 100644 --- a/src/ng/directive/ngTransclude.js +++ b/src/ng/directive/ngTransclude.js @@ -49,9 +49,14 @@ * */ var ngTranscludeDirective = ngDirective({ - controller: ['$transclude', '$element', function($transclude, $element) { - $transclude(function(clone) { - $element.append(clone); + 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); + }); }); }] }); -- cgit v1.2.3