注射用ngBindHtml脚本标记 [英] Injecting a script tag with ngBindHtml
本文介绍了注射用ngBindHtml脚本标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个是用户生成的内容的外部API数据。客户希望与该饲料动态更新了自己的网站,其中包括使用JavaScript的能力。
I have external API data which is a user generated content. The client wants to dynamically update his own site with this feed, including the ability to use JavaScript.
<div ng-bind-html="post.content"></div>
将显示任何内容是HTML或CSS,但不使用JavaScript工作:
Will display anything that is HTML or CSS but does not work with JavaScript:
"content":"<div>Hello Stack</div><script>alert('whats up?');</script>"
我曾尝试包括 ngSanitize
以及使用 NG-结合HTML的不安全
。
没有骰子。
推荐答案
您必须包括jQuery的这个工作。
You have to include jQuery for this to work.
经过一番搜索我碰到<少时href=\"http://stackoverflow.com/a/14088380/1264846\">http://stackoverflow.com/a/14088380/1264846.
例plunkr: http://plnkr.co/edit/zEXXCB459Tp25VJiyyZb?p= preVIEW
这篇关于注射用ngBindHtml脚本标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文