AngularJS is rendering
as text not as a newline

后端 未结 5 1185
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-14 00:10

I am sure this has been asked before but I cannot find the answer.

I have an AngularJS script that is pulling from a DB and then rendering to content. Everything is

5条回答
  •  眼角桃花
    2020-12-14 00:56

    You need to either use ng-bind-html-unsafe ... or you need to include the ngSanitize module and use ng-bind-html:

    with ng-bind-html-unsafe

    Use this if you trust the source of the HTML you're rendering it will render the raw output of whatever you put into it.

    Categories


    OR with ng-bind-html

    Use this if you DON'T trust the source of the HTML (i.e. it's user input). It will sanitize the html to make sure it doesn't include things like script tags or other sources of potential security risks.

    Make sure you include this:

    
    

    Then reference it in your application module:

    var app = angular.module('myApp', ['ngSanitize']);
    

    THEN use it:

    Categories

提交回复
热议问题