javascript - How to show angular data model as HTML? -


i have data-model needs converted or show html. right shows text.

html

<div ng-repeat="item in ornamentfigures" class="ornament-item">     <label for="ornament-{{item.id}}">{{item.svg}}</label>     <input type="radio" id="ornament-{{item.id}}" name="ornament-radio" /> </div> 

controller

$scope.ornamentfigures = ornamentfigures.ornamentfigures; 

service

myapp.service('ornamentfigures', function(){      this.ornamentfigures = [         {id:'03', name:'wit', svg:'<svg></svg>'},         {id:'03', name:'wit', svg:'<svg></svg>'},         {id:'03', name:'wit', svg:'<svg></svg>'},     ];      return this; }); 

are looking ng-bind-html?

replace:

<label for="ornament-{{item.id}}">{{item.svg}}</label> 

with:

<label for="ornament-{{item.id}}" ng-bind-html="item.svg"></label> 

also include ngsanitize in module , include "angular-sanitize.js" in application per the documentation.

instead of binding data is, render html. keep in mind there security implications this. might want try different way if can.


Comments