我正在使用 ckeditor 来获取用户在 textarea 中输入的内容,但是当我想在我的页面中显示/呈现该字段时,它只显示 html 标签而不是呈现的标签! 这很奇怪,因为连标签都没有转义,而且一切看起来都像纯 html 语法,只是没有呈现! 存储在 mongodb 中的是这样的:
"longDesc" : "<p style=\"text-align: left;\">We need creation of <strong>7 animated banners</strong>.</p>\n\n<p style=\"text-align: left;\">We need to remake to dynamic form. We provide you open source data and technical specifications.</p>\n"
并在 View 中使用 angularjs 双括号来显示此表达式。
{{job.longDesc}}
输出就是:
<p style=\"text-align: left;\">We need creation of <strong>7 animated banners</strong>.</p>\n\n<p style=\"text-align: left;\">We need to remake to dynamic form. We provide you open source data and technical specifications.</p>\n
最佳答案
看看ngBindHtml .您只需要:
$scope.myHTML = '<p>test</p>';
....
<div ng-controller="ExampleController">
<p ng-bind-html="myHTML"></p>
</div>
您需要在您的应用程序依赖项中包含 ngSanitize 以使 ng-bind-html 工作。这是一个 Plunker 示例:
关于javascript - HTML 标签未在 div 内呈现(ckeditor),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32355796/