How to render text into HTML in AngularJS

Surjeet Bhadauriya

I have a variable in a scope with some HTML content. I want to render it as HTML on the webpage, but in my case it displays as full text. Can anyone help me?

This is my code:-

//contoller.js

$scope.message = '<b><i>result has been saved successfully.</i></b>';

//demo.html

<p ng-bind="message"></p>
KP Chundawat

You need to inject $sce service into your controller or Directive etc. and use $sce service like this:-

$scope.Message = $sce.trustAsHtml("<b><i>result has been saved successfully.</i></b>");

And bind this in your HTML page e.g;

<p ng-bind-html = "Message"></p>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to render html as text

From Dev

How to render raw html with AngularJS?

From Dev

How to render html in Angularjs directive?

From Dev

How to render raw html with AngularJS?

From Dev

AngularJS + Json: How to render html

From Dev

AngularJS: How to render HTML in $scope variable in view?

From Dev

How to render HTML encoded text in SLIM

From Dev

AngularJS Render HTML in textarea

From Dev

How to render a HTML tag from json value using angularJs

From Dev

How would I render html tags inserted via compile in AngularJS?

From Dev

how to read a text file and display it in html (angularjs)

From Dev

How to display HTML text in angularjs / bootstrap?

From Dev

Render json instead of html with angularjs

From Dev

Angularjs render html in special characters

From Dev

Ruby on Rails: How to render file as plain text (without any HTML)

From Dev

How to render text from javascript object in HTML form

From Dev

How to render text inside jsx "tag" like a normal HTML?

From Dev

How to render html dynamically?

From Dev

How to render Html with smarty

From Dev

How to render angularjs content conditional?

From Dev

how to render stream file which has mimetype "text/html" or 'text/plain' in JSF panel

From Dev

AngularJS-Render HTML embed codes as a layout

From Dev

Render Razor variable inside AngularJS Html

From Dev

AngularJS - Render HTML tags that are contained in a string

From Dev

MVC, Render HTML page which includes AngularJS

From Dev

Render Razor variable inside AngularJS Html

From Dev

How to show some text in html when certain condition is met in AngularJS?

From Dev

How to push text from html input into AngularJS array?

From Dev

How to push text from html input into AngularJS array?

Related Related

  1. 1

    How to render html as text

  2. 2

    How to render raw html with AngularJS?

  3. 3

    How to render html in Angularjs directive?

  4. 4

    How to render raw html with AngularJS?

  5. 5

    AngularJS + Json: How to render html

  6. 6

    AngularJS: How to render HTML in $scope variable in view?

  7. 7

    How to render HTML encoded text in SLIM

  8. 8

    AngularJS Render HTML in textarea

  9. 9

    How to render a HTML tag from json value using angularJs

  10. 10

    How would I render html tags inserted via compile in AngularJS?

  11. 11

    how to read a text file and display it in html (angularjs)

  12. 12

    How to display HTML text in angularjs / bootstrap?

  13. 13

    Render json instead of html with angularjs

  14. 14

    Angularjs render html in special characters

  15. 15

    Ruby on Rails: How to render file as plain text (without any HTML)

  16. 16

    How to render text from javascript object in HTML form

  17. 17

    How to render text inside jsx "tag" like a normal HTML?

  18. 18

    How to render html dynamically?

  19. 19

    How to render Html with smarty

  20. 20

    How to render angularjs content conditional?

  21. 21

    how to render stream file which has mimetype "text/html" or 'text/plain' in JSF panel

  22. 22

    AngularJS-Render HTML embed codes as a layout

  23. 23

    Render Razor variable inside AngularJS Html

  24. 24

    AngularJS - Render HTML tags that are contained in a string

  25. 25

    MVC, Render HTML page which includes AngularJS

  26. 26

    Render Razor variable inside AngularJS Html

  27. 27

    How to show some text in html when certain condition is met in AngularJS?

  28. 28

    How to push text from html input into AngularJS array?

  29. 29

    How to push text from html input into AngularJS array?

HotTag

Archive