I have an AngularJS app, I need to have the string to be filtered (with a filter) to show the correct HTML formatting:
This:
$scope.text = "This is <strong>GREAT</strong>";
Needs to be:
This is GREAT
(And other HTML tags, like <br> and so forth should be working)
It should work thru a filter, like:
{{text | toHTML}}
I know about ng-bind-html BUT I need it to work thru a filter and NOT with ng-bind-html.
I found some examples where the filter needs to be constructed for each step (for the <a> there is a code, for <br> another one...)
Is there a way to filter a scope element to handle the HTML formatting?
ngSanitizein your angular module?$sce.trustAsHtmlas explain in the answers below, but beware that the html you display is trusted and doesn't come from a user. Otherwise it's a high risk of XSS flaws.