Skip to content Skip to sidebar Skip to footer

Ng-bind-html Inside Ng-repeat

I'm making a custom autosuggest component where I hit a web service with a search term and it returns a list of suggestions which I display. My issue is, I want to bold the matchin

Solution 1:

You don't need to define $scope.html because you are already assigning the HTML to title.

You just need to use it right in your ng-repeat loop:

li.fade-in(ng-repeat="item in items")
  h2: a(ng-href="{{item.url}}" ng-bind-html="item.title")

I also recommend using ng-href instead of just href, because you are using an angular expression for the link ;)

Post a Comment for "Ng-bind-html Inside Ng-repeat"