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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -