2

I have this data from a json, it's html code, how can I print it like html because it only seems to print it as a String:

   "content": "Más pruebas\u003cbr /\u003e\n\u003cbr /\u003e\n\u003cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003e\n\u003ca href=\"https://2.bp.blogspot.com/-CK43Mn516s4/WEmWGS9eoaI/AAAAAAAASg0/k4213387TNA0XInyTNgqaqEn4YYanzCZgCLcB/s1600/Monsters-Inc-Concept-Art.jpg\" imageanchor=\"1\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003e\u003cimg border=\"0\" height=\"174\" src=\"https://2.bp.blogspot.com/-CK43Mn516s4/WEmWGS9eoaI/AAAAAAAASg0/k4213387TNA0XInyTNgqaqEn4YYanzCZgCLcB/s200/Monsters-Inc-Concept-Art.jpg\" width=\"200\" /\u003e\u003c/a\u003e\u003c/div\u003e\n\u003ca href=\"http://google.com/\"\u003eGoogle\u003c/a\u003e",

I'm using angularjs 1.x

Thank you all!

2 Answers2

2

As you are receiving HTML code from your data source you should use the $sce service to escape it. Use

$sce.trustAsHtml(data)

Here is a plunker to demonstrate with your data which then displays the string as HTML:

https://plnkr.co/edit/LXLHhXCJ4zEZhFJSeT5W?p=preview

jtsnr
  • 1,180
  • 11
  • 18
0

Use:

<div html="scopeVariable"></div>
Yoan
  • 2,158
  • 1
  • 12
  • 21