1

Now I know to use ngSanitize and ng-bind-html, but can I use it with ng-repeat where I have the following logic:

<div ng-repeat="(k, v) in specs.webdev">
    <h3>{{::v["job-title"]}}</h3>
    <p>{{::v["job-body"]}}</p>
    United Kingdom Apply Here:
    <p>{{::v["job-apply"]}}</p>
</div>

specs (where I have multiple html tags) is retrieved from JSON file with $http.get and parsed with .then. So, values in "job-title", "job-body", "job-apply" contain HTML tags that I'm trying to display here.

How can I use ng-bind-html here?

1
  • Do the job-title, job-body and job-apply properties contain HTML tags which you want to maintain to display as correct HTML? Just trying to understand the question more. Commented Dec 19, 2016 at 14:45

1 Answer 1

3

If I understand well, just doing

<div ng-repeat="(k, v) in specs.webdev">
  <h3 ng-bind-html="::v['job-title']"></h3>
  <p ng-bind-html="::v['job-body']"></p>
  United Kingdom Apply Here:
  <p ng-bind-html="::v['job-title']"></p>
</div>

That will render the content of v['job-title'] and other properties as HTML

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, wow.. I've learned something new. Never thought to put it inside the html tag like this. :)

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.