How to render raw html with AngularJS

0 votes

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>
Jun 20, 2020 in Java-Script by kartik
• 37,510 points
4,506 views

1 answer to this question.

0 votes

Hello @kartik,

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>

Hope this is helpful!

To know more about Angular, It's recommended to join Angular course today.

Thanks.

answered Jun 20, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

How to set outerHTML with jQuery?

hello @kartik, This is innterHTML because it's inside ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
1,825 views
0 votes
1 answer

How to call jQuery UI Dialog with ASP.NET button postback?

Hello @kartik, To solve the problem with ASP:Button ...READ MORE

answered Apr 28, 2020 in Java-Script by Niroj
• 82,880 points
3,080 views
0 votes
1 answer

How to use React Router with Laravel?

Hii Kartik, Create a route that maps everything ...READ MORE

answered Apr 29, 2020 in Java-Script by Niroj
• 82,880 points
6,280 views
0 votes
1 answer

How to create dynamic href in react render function?

Hello @kartik, Use string concatenation: href={'/posts/' + post.id} The JSX ...READ MORE

answered May 18, 2020 in Java-Script by Niroj
• 82,880 points
10,541 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
21,750 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
2,647 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
2,504 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
41,371 views
0 votes
1 answer

How to Store PHP variable with HTML in JavaScript in Laravel Blade Template?

Hello @kartik, The double curly brackets {{ }} will always ...READ MORE

answered Jun 11, 2020 in Java-Script by Niroj
• 82,880 points
16,609 views
0 votes
1 answer

How can I send a message to a particular client with socket.io?

Hii, You can try the code below: io.to(socket.id).emit("event", data); whenever ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
27,054 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP