diff options
| author | Igor Minar | 2013-07-18 11:30:32 -0700 |
|---|---|---|
| committer | Igor Minar | 2013-07-22 11:32:50 -0700 |
| commit | 683fd713c41eaf5da8bfbf53b574e0176c18c518 (patch) | |
| tree | 7cac528b64d0831e36d14bf8c78c417158fb6a2e /src/ng/directive/ngTransclude.js | |
| parent | 3591ae010398da67950eeefe4f8613e69bb786eb (diff) | |
| download | angular.js-683fd713c41eaf5da8bfbf53b574e0176c18c518.tar.bz2 | |
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
Diffstat (limited to 'src/ng/directive/ngTransclude.js')
| -rw-r--r-- | src/ng/directive/ngTransclude.js | 11 |
1 files changed, 8 insertions, 3 deletions
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); + }); }); }] }); |
