diff --git a/src/ng/compile.js b/src/ng/compile.js index 63eb52fcb77f..fed4d2d93fe3 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -847,6 +847,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { ? JQLitePrototype.clone.call($compileNodes) // IMPORTANT!!! : $compileNodes; + if ( $linkNode.length === 0 && parentBoundTranscludeFn ) { + $linkNode = parentBoundTranscludeFn(scope); + } + forEach(transcludeControllers, function(instance, name) { $linkNode.data('$' + name + 'Controller', instance); }); diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 992d7edc51e1..f74cdf0784d8 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -4097,6 +4097,37 @@ describe('$compile', function() { }); + describe('collocated nested transcludes', function() { + + beforeEach(module(function($compileProvider) { + + $compileProvider.directive('inner', valueFn({ + restrict: 'E', + transclude: true, + template: '' + })); + + $compileProvider.directive('outer', valueFn({ + restrict: 'E', + transclude: true, + template: '' + })); + + })); + + + // Issue #8914 + it('should render nested transclusion at the root of a template', inject(function($compile, $rootScope) { + + element = $compile('
transcluded content
')($rootScope); + $rootScope.$digest(); + expect(element.text()).toEqual('transcluded content'); + + })); + + }); + + describe('nested transcludes', function() { beforeEach(module(function($compileProvider) {