Anindya Dutta
Anindya Dutta

Reputation: 1982

How to convert tags in HTML using AngularJS

I am getting a JSON using AJAX in AngularJS. One of the attributes in the object (say, sample), has a string "<b>String</b>".

I populate this into a table as follows: <td>{{item.sample}} </td>

This gives an output: <b>String</b> on the webpage, when I was actually trying to display String.

Since it is a JSON string, what is currently happening makes sense. How do I use this string and somehow evaluate it so that I see the bold string on the webpage?

Upvotes: 0

Views: 26

Answers (1)

Gosha_Fighten
Gosha_Fighten

Reputation: 3868

Use ngBindHtml directive to render your text.

<td ng-bind-html="item.sample"></td>

Upvotes: 1

Related Questions