I am new to angularjs and using this directive as below. When this directive gets loaded on HTML file, it should treat these HTML as actual HTML rather than string but it is not working. I am using angular 1.4.7 version.
Please help!! I am adding below HTML as String because I am getting that HTML as String from service dynamically. So this is just example that I am adding here to see how can we display html value on angular html if it is coming as string.
angular.module('my.directive', [])
.directive("myDirective", function(){
return {
restrict: "EA",
scope: false,
template: "<div class='con'>"+
"<div>'<p><i><strong>some text</strong></i></p>'</div>"+
"</div>"
};
});
I have tried multiple ways to fix it here but no luck. I have tried using "ng-bind-html-unsafe" and "ng-bind-html" but none of them works correctly.
I have even tried using direct HTML with ng-bind-html and unsafe as well but no luck there as well.
I have simply tried below HTML but that doesn't work as well.
<div ng-repeat="list in lists">
<div class="content">
<div ng-bind-html='<p><i><strong>some text</strong></i></p>'></div>
</div>
</div>
Also below doesn't work.
<div ng-repeat="list in lists">
<div class="content">
<div ng-bind-html-unsafe='<p><i><strong>some text</strong></i></p>'></div>
</div>
</div>