In this answer, I'm trying to follow, it's suggested to implement a function in my JS like this. As shown, I've tried both with the further call to trustAsHtml(...)
and a hard coded string. Same result in both cases.
$scope.renderHtml = function (htmlCode) {
return "whatever";
// return $sce.trustAsHtml(htmlCode);
};
I also implemented the markup as follows. Only the first line shows (plain mustaches) while the others render nothing visible. I've tried with hard coded value as well as the variable with/sans the mustache.
<td ng-if="certificate.details">
{{certificate.details}}
<!--<div ng-bind-html="$scope.renderHtml(34343)"></div>-->
<!--<div ng-bind-html="$scope.renderHtml(certificate.details)"></div>-->
<!--<div ng-bind-html="$scope.renderHtml({{certificate.details}})"></div>-->
</td>
I'm not sure how to bite this one and all the resources point to the same Angular directive - ng-bind-html
. What am I doing wrong? How can I troubleshoot it further?
Bottom line, I'm trying to render a string in my object as HTML for styling. Can I do that in a totally different (and easier) way to begin with, perhaps? (Still would like an answer to this question, should there be such an easier approach.)