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?

eric.dummy
  • 399
  • 1
  • 8
  • 24
  • 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. – Giovani Vercauteren Dec 19 '16 at 14:45

1 Answers1

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

Daniel Santiago
  • 205
  • 1
  • 8