Home > Net >  AngularJs: Display HTML elements from string variable in JSP page
AngularJs: Display HTML elements from string variable in JSP page

Time:03-18

I'm using AngularJs and I need to render into a JSP page the HTML elements that are into a string variable in the Controller as below:

$scope.myVar = "<h1>Title</h1><p>More information <a href="linkhere">Click here</a></p>";
    

So in JSP page I have something like:

<div >
    {{myVar}}
</div>

But the UI only prints the plain text of the variable. How can I solve this situation?

CodePudding user response:

Use AngularJs ng-bind-html directive to render HTML. ( Docs )

<div  ng-bind-html="myvar"></div>
  • Related