with decodeText $scope.decodeTe...">

Ng-html-bind skip style tag

I have 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 rendering

[{"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 causes this?

+4
source share
1 answer

ng-bind-htmland are $sce.trustAsHtmlalways used together to display flat HTML.

It seems you are missing a piece $scein your code.

Try this instead:

$scope.decodeText = function (data) {
    return $sce.trustAsHtml(data);
}
+4
source

Source: https://habr.com/ru/post/1530408/


All Articles