I want to parse a string as HTML inside a data attribute with AngularJS -


i'm using ngsanitize parse var:

var icon = $sce.trustashtml(' '); 

but, can't use ng-bind-html or ng-bind-html-unsafe in view trying add value data tag:

<i class="icon" data-icon="{{ message.icon }}"></i> 

results in:

<i class="icon" data-icon="&#x020;"></i> 

i tried:

<i class="icon" ng-attr-data-icon="message.icon"></i> 

also didn't work.

any ideas?

what when this?

var icon = $sce.trustashtml('&#x020;'); console.log(icon); $scope.message = icon; 

how instead of

var icon = $sce.trustashtml('&#x020;'); 

you do:

$scope.someuniqueiconname = $sce.trustashtml('&#x020;'); 

then in html do:

<i class="icon" data-icon="{{someuniqueiconname}}"></i> or <i class="icon" ng-attr-data-icon="someuniqueiconname"></i> 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -