errorcode errorcode - 5 months ago 77
AngularJS Question

HTML text in ionic list

i have following list:

<ion-list>
<ion-item ng-repeat="item in productlistitems">
{{ item.name }}!
</ion-item>
</ion-list>


item.name is with HTML tags, but they appear as plain text.

How can I achieve that the HTML code gets "executed"?

Answer

In order to render HTML, use the "ng-bind-html" directive like this:

<div ng-bind-html="item.name"></div>

In your controller, you need to "trust" the data using the $sce service like this:

$scope.item.name = $sce.trustAsHtml("your HTML here");