ng-bind-html-unsafe
does not support directive. We have to somehow compile the bound html.
Try compiling it by writing a directive:
app.directive("compile",function($compile,$timeout){
return {
priority:-1,
link:function(scope, element, attrs) {
$timeout(function(){
$compile(element.contents())(scope);
});
}
}
});
Use it:
<div ng-bind-html-unsafe="myHTML" compile></div>
DEMO
Another solution is writing our own ng-bind-html
app.directive("myNgBindHtml",function($compile){
return {
link:function(scope, element, attrs) {
scope.$watch(attrs.myNgBindHtml,function(value){
element.html(value);
$compile(element.contents())(scope);
})
}
}
});
DEMO