Answer the question
In order to leave comments, you need to log in
AngularJS, How to output HTML data from JSON if ngBind doesn't help?
A JSON file like this comes from the server:
{
"text": "<p style='color: #0000ff; padding: 30px;'>Guide</p>",
"name": "Post"
}
ngBind
and ngBindHtml
, but it ended up outputting <p>Guide</p>
. style='color: #0000ff; padding: 30px;'
?
Answer the question
In order to leave comments, you need to log in
To solve this problem, make a special you can create a special filter. At least this is my choice for solving this problem
.filter('asHTML', function($sce) {
return function(input) {
return $sce.trustAsHtml(input);
};
})
<span ng-bind-html="var | asHTML"></span>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question