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=" "></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(' '); console.log(icon); $scope.message = icon;
how instead of
var icon = $sce.trustashtml(' ');
you do:
$scope.someuniqueiconname = $sce.trustashtml(' ');
then in html do:
<i class="icon" data-icon="{{someuniqueiconname}}"></i> or <i class="icon" ng-attr-data-icon="someuniqueiconname"></i>
Comments
Post a Comment