Reputation: 155
I am receiving this json array and using angular to display it.
Shorted example:
$scope.results = [{"description": "\u003ca href=\"http://google.com \" target=\"_blank\"\u003eClick Here\u003c/a\u003e"}];
The problem is that the value contains html code or unicode characters that don't work properly.
I've searched and tried ng-bind-html with no luck.
In the html source code I get this:
<a href="http://google.com " target="_blank">Click Here</a>
Instead of this:
<a href="http://google.com " target="_blank">Click Here</a>
Here is an example Plunker with my problem
Upvotes: 0
Views: 907
Reputation: 136144
You need to use ng-bind-html
and then we could get the trusted Html in anchor tag rendered on the page.
Markup
<span ng-repeat="result in results"
ng-bind-html="result.description | unsafe">
</span>
Upvotes: 1