How to output html through AngularJS template?

后端 未结 5 2044
醉梦人生
醉梦人生 2020-12-15 16:27

{{ revision.title }}

The title outputs fine, but the content - does

5条回答
  •  抹茶落季
    2020-12-15 17:28

    according to Official AngularJs Doc about ngBindHtml you must inject ngSanitize into your app dependencies

    Evaluates the expression and inserts the resulting HTML into the element in a secure way. By default, the resulting HTML content will be sanitized using the $sanitize service. To utilize this functionality, ensure that $sanitize is available, for example, by including ngSanitize in your module's dependencies (not in core Angular). In order to use ngSanitize in your module's dependencies, you need to include "angular-sanitize.js" in your application.

    Then you can install ngSanitize module by there ways:

    1 - using bower

    bower install --save angular-sanitize
    

    2 - using npm

    npm install --save angular-sanitize
    

    3 - manually by download angular-sanitize.js file from code.angularjs.org path which include all angularJs files categories by version number like @Xeen answer

    See More about install ngSanitize module from Oficial angularJs github repository for install angular-sanitize

提交回复
热议问题