0

I am using angularjs. Here I have a string fetched from database and it is in html form like this

$scope.data = '<p>this is first line </br> this is second line</p>';

and when i dispaly it like

{{$scope.data}}

It actually come as it is without html formatted like

<p>this is first line </br> this is second line</p>

But I want as

this is first line
this is second line
1

2 Answers 2

3

Use $sce:

$scope.data = $sce.trustAsHtml('<p>this is first line </br> this is second line</p>');

HTML

<div ng-bind-html="data"></div>
Sign up to request clarification or add additional context in comments.

3 Comments

but i want to use it inside ng-repeat inside <td>.Is it possible with this?
<tr ng-repeat="user in $data"> <td data-title="'Name'" filter="{ 'name': 'text' }" sortable="'name'"> {{user.post_title}} </td> <td data-title="'Content'"> {{user.post_content}} </td> </tr>
I actually wants to use this in {{user.post_content}}
0

You can use Angular's $compile tool, you can find the documentation here.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.