Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 2 down vote accepted

You have to include jQuery for this to work.

After some searching I came across http://stackoverflow.com/a/14088380/1264846.

Example plunkr: http://plnkr.co/edit/zEXXCB459Tp25VJiyyZb?p=preview

share|improve this answer
 
+1 It works. But that is rediculous. They call support for this "black magic" haha. –  Dan Kanze Jul 4 '13 at 3:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.