Dvora
Dvora

Reputation: 1185

Show user input as HTML - angular1

I have in my controller a variable, which is defined on the $scope, which contains an html input.

function init() {
        $scope.message = params.message;
    }

Where params.message could be for example something like this:

<h1>Hellow world</h1><p>Hi again</p><br><br> <b> End </b>

in the html I use it like this:

    <div ng-show="showTab == 'EN'">
        <div class='library-padding'>
            <p>{{message}}></p>
        </div>
    </div>

I want it to be shown as parsed html, meaning that the tags themselves will not appear, but it's displayed as plain text, including all tags.

How can I make this input text parsed and behaving like html?

Thanks!

Upvotes: 0

Views: 23

Answers (1)

HankScorpio
HankScorpio

Reputation: 3651

You're looking for the ngBindHtml directive:

https://docs.angularjs.org/api/ng/directive/ngBindHtml

<div ng-show="showTab == 'EN'">
    <div class='library-padding'>
        <p ng-bind-html="message"></p>
    </div>
</div>

Upvotes: 1

Related Questions