Marc Rasmussen
Marc Rasmussen

Reputation: 20565

sce trust as html does not print the HTML

So i have the following HTML:

<p>Mmmhmmmmmm</p>

Very simple (however it does get more advanced than that but for the time being lets use the above as an example)

This value is stored in a $scope value: $scope.selected.textContent

And so in order to print it i used the following:

    <div class="row">
    <div class="col-xs-12">
        {{$sce.trustAsHtml(selected.textContent)}}
    </div>
</div>

However it prints nothing.

if i do the following:

{{$sce.trustAsHtml(selected.textContent) || 'Hello'}}

It prints out Hello.

Can anyone tell me what im doing wrong?

Upvotes: 0

Views: 653

Answers (1)

iurii
iurii

Reputation: 4230

Use ng-bind-html instead

<div class="col-xs-12" ng-bind-html="htmlHere">
</div>

and in your controller

$scope.htmlHere = $sce.trustAsHtml('<p>test</p>')

Upvotes: 2

Related Questions