-1

I am trying create superscript html in my angular

$scope.Volume = 'm<sup>3</sup>';

I always get html like this

<div class="ng-binding">Volume<br>(m&lt;sup&gt;3&lt;/sup&gt;)</div>

Becuase of above html generated, it alwyas shows m<sup>3</sup> on render page rather than desired output i.e. m superscript 3.

How i can use html in angular controller?

1

2 Answers 2

2

In your case you can bind the html with

<div ng-bind-html="Volume"></div> 

See the official documentation: See: https://docs.angularjs.org/api/ng/directive/ngBindHtml

Sign up to request clarification or add additional context in comments.

1 Comment

How i can do it inside controller?
1

You can't use HTML in templates directly. You can use ng-bind-html, but it will by default also strip out potentially problematic tags like <script>. So you also need to include ngSanitize.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.