I understand that a lot of time has passed since the publication of this question, but I hope you find the following useful.
I was quite long and hard in this matter (transclusion), I tried several ways to achieve what you need @jcubic, and finally I came across a solution that is really reliable and quite simple.
... replace: false, transclude: false, compile: function( tElement, tAttributes ) { // store your "transcluded" content of the directive in the variable var htmlContent = tElement.html(); // then remove it tElement.html(''); return function postLink(scope, elem, attrs) { // then html var is available in your link! var $html = $('<div />',{ html:htmlContent }); // for much easier manipulation (so you can use DOM functions - you can also manipulate directly on htmlContent string) // so you can manipulate the content however you want scope.myVariable = true; $html.find('li').attr('ng-hide', 'myVariable'); // add native directive $html.removeClass('inner-content').addClass('my-inner-content'); // add/remove class $html.find('#myElement').attr('my-directive',''); // add custom directive etc. etc. // after you finished you just need to compile your html and append your directive element - also however you want // you also convert back $html to the string elem.append( $compile( $html.html() )(scope) ); // append at the end of element /* or: elem.find('.my-insert-point').html( $compile( $html.html() )(scope) ); // append the directive in the specific point elem.find('[my-transclude]').html( $compile( $html.html() )($parent.scope) ); // once the scope:true it will be the same as native transclusion ;-) scope.variable = $html.html(); // or you can probably assign to variable and use in your template with bind-html-compile (https://github.com/incuna/angular-bind-html-compile) - may need $sce.trustAsHtml */ } } ...
So, you can see that you have full control over your "translated" content, and you donβt even need to translate !:-)
ps. I tested it with Angular 1.4. Not sure if it works with the replacement: true (I did not want to test it, since this is a minor nuisance if it is not). You can use the preliminary and post links, as usual, you use in the compilation function, and you need to insert the compile command in your directive.
source share