Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to parse Html text using Angularjs?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.38k
    Comment on it

    If our text contains some html content, then we have to use ng-bind-html directive in angular js, else our html content will not be parsed and will be rendered as it is.

    Example:

    If our text is  

    $scope.Val = "<span> Something </span>"

    and we write this text within curly brackets as follows:

    <div> {{Val}}  </div>

    then the text will be rendered as it is i.e.   <span> Something </span>

    Therefore in order to get this html content parsed we have to write it as follows:

    <div ng-bind-html="Val"></div>

    Now the text will be rendered as Something .

     

    Note: Make sure to include ngSanitize module on your app eg: var app = angular.module('myApp', ['ngSanitize']);

                                                                            Hope it helps...!

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: