Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
184
rated 0 times [  191] [ 7]  / answers: 1 / hits: 21686  / 9 Years ago, fri, august 7, 2015, 12:00:00

I'm creating an AngularJS single page application.
The data will be fetched from a webservice in json-format.



The problem is that some text elements come with preformatted html tags



json output:



{
text: <p><span style=text-decoration: underline;><strong>test text</string></span></p>
}


Now how can I display this text and render the html directly, so that only test is shown to the user and the rest serves as markup?



<h1>{{data.text}}</h1>

More From » html

 Answers
98

You need to add ng-bind-html=data.text to your h1 tag.



Your html would look like:



<h1 ng-bind-html=data.text></h1>


Documentation: ngBindHtml


[#65496] Thursday, August 6, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jadyngraysons

Total Points: 455
Total Questions: 109
Total Answers: 98

Location: Trinidad and Tobago
Member since Fri, May 8, 2020
4 Years ago
jadyngraysons questions
Thu, Apr 23, 20, 00:00, 4 Years ago
Sat, Jan 18, 20, 00:00, 4 Years ago
Tue, Dec 31, 19, 00:00, 5 Years ago
;