In your Plunker, you use ng-bind-html , which does not compile HTML for you. You can create a new directive that will do this for you.
Source code for ng-bind-html :
var ngBindHtmlDirective = ['$sce', '$parse', '$compile', function($sce, $parse, $compile) { return { restrict: 'A', compile: function ngBindHtmlCompile(tElement, tAttrs) { var ngBindHtmlGetter = $parse(tAttrs.ngBindHtml); var ngBindHtmlWatch = $parse(tAttrs.ngBindHtml, function getStringValue(value) { return (value || '').toString(); }); $compile.$$addBindingClass(tElement); return function ngBindHtmlLink(scope, element, attr) { $compile.$$addBindingInfo(element, attr.ngBindHtml); scope.$watch(ngBindHtmlWatch, function ngBindHtmlWatchAction() {
Select a name for the new directive, for example compile-html .
Replace tAttrs.ngBindHtml with tAttrs.compileHtml (or whatever name you choose).
You need to replace $sce.getTrustedHtml with $sce.trustAsHtml , or you get Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context.
Then you need to call $compile :
$compile(element.contents())(scope);
Full directive:
app.directive('compileHtml', ['$sce', '$parse', '$compile', function($sce, $parse, $compile) { return { restrict: 'A', compile: function ngBindHtmlCompile(tElement, tAttrs) { var ngBindHtmlGetter = $parse(tAttrs.compileHtml); var ngBindHtmlWatch = $parse(tAttrs.compileHtml, function getStringValue(value) { return (value || '').toString(); }); $compile.$$addBindingClass(tElement); return function ngBindHtmlLink(scope, element, attr) { $compile.$$addBindingInfo(element, attr.compileHtml); scope.$watch(ngBindHtmlWatch, function ngBindHtmlWatchAction() { element.html($sce.trustAsHtml(ngBindHtmlGetter(scope)) || ''); $compile(element.contents())(scope); }); }; } }; } ]);
Using:
<div compile-html="tab.content"></div>
Demo: http://plnkr.co/edit/TRYAaxeEPMTAay6rqEXp?p=preview