admin管理员组文章数量:1336699
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>
Will display anything that is HTML or CSS but does not work with JavaScript:
"content":"<div>Hello Stack</div><script>alert('whats up?');</script>"
I have tried including ngSanitize
as well as using ng-bind-html-unsafe
.
No dice.
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>
Will display anything that is HTML or CSS but does not work with JavaScript:
"content":"<div>Hello Stack</div><script>alert('whats up?');</script>"
I have tried including ngSanitize
as well as using ng-bind-html-unsafe
.
No dice.
Share Improve this question edited Mar 4, 2016 at 15:00 isherwood 61.2k16 gold badges121 silver badges169 bronze badges asked Jul 4, 2013 at 2:27 Dan KanzeDan Kanze 18.6k28 gold badges84 silver badges135 bronze badges1 Answer
Reset to default 6You have to include jQuery for this to work.
After some searching I came across https://stackoverflow./a/14088380/1264846.
Example plunkr: http://plnkr.co/edit/zEXXCB459Tp25VJiyyZb?p=preview
本文标签: javascriptInjecting a script tag with ngBindHtmlStack Overflow
版权声明:本文标题:javascript - Injecting a script tag with ngBindHtml - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742420602a2471580.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论