Angular recognized that a more flexible ng-transclude would be useful:
https://github.com/angular/angular.js/issues/5489
One suggested workaround is to define your own override for ng-transclude , which allows you to do the following:
<div ng-transclude="sibling"></div> <div ng-transclude="parent"></div> <div ng-transclude="child"></div>
Source for custom ng-transclude :
.config(function($provide){ $provide.decorator('ngTranscludeDirective', ['$delegate', function($delegate) { // Remove the original directive $delegate.shift(); return $delegate; }]); }) .directive( 'ngTransclude', function() { return { restrict: 'EAC', link: function( $scope, $element, $attrs, controller, $transclude ) { if (!$transclude) { throw minErr('ngTransclude')('orphan', 'Illegal use of ngTransclude directive in the template! ' + 'No parent directive that requires a transclusion found. ' + 'Element: {0}', startingTag($element)); } var iScopeType = $attrs['ngTransclude'] || 'sibling'; switch ( iScopeType ) { case 'sibling': $transclude( function( clone ) { $element.empty(); $element.append( clone ); }); break; case 'parent': $transclude( $scope, function( clone ) { $element.empty(); $element.append( clone ); }); break; case 'child': var iChildScope = $scope.$new(); $transclude( iChildScope, function( clone ) { $element.empty(); $element.append( clone ); $element.on( '$destroy', function() { iChildScope.$destroy(); }); }); break; } } } })
source share