0

I am trying to bind html to my div element, but dont really know how to do it. I am not great with angularjs, but should ng-bind-html do the trick?

This is how I tried to do it,

<div ng-bind-html="{{tile.Info.Title}}"></div>
<div ng-bind-html="{{tile.Info.Content}}"></div>

In angular 2 its just [innerHTML], cant get it to work here, any suggestion?

2
  • 4
    general rule: if it has ng-, then you don't need curly brackets {{ ... }} Commented Dec 19, 2017 at 9:54
  • Possible duplicate of AngularJS data bind in ng-bind-html? Commented Dec 19, 2017 at 10:04

2 Answers 2

2

You can get an example here.

<div ng-controller="ExampleController">
 <p ng-bind-html="myHTML"></p>
</div>
Sign up to request clarification or add additional context in comments.

Comments

1

As also suggested in comments by @Aleksey when you are using ng- there is no need to use curly brackets {}. So your code should be like:

<div ng-bind-html="tile.Info.Title"></div>
<div ng-bind-html="tile.Info.Content"></div>

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.