I have an ng-bind like this
<p ng-bind-html="decodeText(item.description)"></p>
with decodeText
$scope.decodeText = function (data) {
return data
}
however, the following json loses the style attribute style="color:#ff0000;"
when rendered
[{"title":"I am here","date_received":"Feb 28, 2014","description":"<p>EE)\u00a0 <span style=\"color:#ff0000;\"> accepted<\/span><\/p>\n<p>HH)\u00a0 <span style=\"color:#ff0000;\">I am\nhere; <\/span><strong>\u00a0<\/strong><\/p>"}
what's causing this?
ng-bind-html
and $sce.trustAsHtml
are always used together for displaying flat HTML.
It seems you are missing the $sce
part in your code.
Try this instead:
$scope.decodeText = function (data) {
return $sce.trustAsHtml(data);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With