"Problem description"
One of the Angularjs's strengths is his data-two-way binding capabilities-----> ng-bind
and for Formng-model
However, in our project, we will encounter a situation where the data returned in the background with a variety of HTML tags
When Angularjs output HTML, browsers do not parse these HTML tags
Through the API, it is found that ng-bind-html
the output of HTML is realized through instruction.
But it doesn't work, and the HTML code is displayed in the browser.
"Solution"
It was later discovered that the HTML display was also required through the $SCE service.
Angular.module ("list", []). Controller ("Bloglistctrl", Bloglistctrl). Filter (
' to_trusted ', [' $sce ', function ($ SCE) {return
function (text) {return
$sce. trustashtml (text)
}
}]
Here, a filter is built through $SCE to filter out the HTML of the output.
This allows the normal output of HTML tags via angularjs, and is parsed by the browser
Summary
The above is the entire content of this article, I hope that the content of this article for everyone's study or work to bring certain help, if you have questions you can message exchange.