22

My database stores product information, and a lot of this is organised into lists. I load the data into Angular as $scope.post.

For instance,

$scope.post.size_description = '<li> Fits true to size. Take your normal size\r</li>
   <li> Slim-cut, mid-rise style</li>
   <li> Long in length, alter to fit</li>
   <li> Model wears an IT 48\r</li>
   <li> Model measures: waist size 32, height 6\'1"/ 185cm\r</li>'.

When I try to load this data into my Angular app, it gets rendered as text (i.e. the <li> are not parsed). I understand this probably happens for security reasons, but is there any way around it?

3

2 Answers 2

14

As Damax has said here: https://stackoverflow.com/a/11640420/769083

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

1 Comment

ng-bind-html-unsafe has been depreciated since Angular 1.2. See stackoverflow.com/questions/9381926/…
8

ngBindHtml worked for me. See more in the docs here: https://docs.angularjs.org/api/ng/directive/ngBindHtml

<div ng-bind-html="post.size_description"></div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.