Sunday, 4 May 2014

AngularJS: How do I render HTML in an ng-repeat?

Rendering HTML with Angular should be a simple task - ng-bind-html should do the trick. (see here).

However, I was struggling to do the same thing in an 'ng-repeat'. I tried using $sanitize, but that did not work. Eventually, I found the solution on stackoverflow: instead of having the iteration sitting above the rendering, one can consolidate the two to produce the required result.

So
                <span ng-repeat="item in items" me-update-flexslider="y">
   <span class="ng-bind-html:{{item}}"></span>
                </span>
became

                <span ng:repeat="item in items" ng-bind-html="item"></span>

No comments:

Post a comment