Javascript in View not working?


I have a 3rd party widget that is included via javascript file. The code itself just writes out some html essentially (document.write); but for whatever reason I can’t get any javascript to execute in the view.

So I tried something as simple as this in the view doesn’t do anything, no errors nothing.

<script type="text/javascript">console.log("hello");</script>

What’s up?


Angular filters out javascript to prevent certain attack vectors.
You need to learn to write a directive in AngularJS to integrate 3rd party widgets. It’s pretty easy to do.


I was able to inject your script sample into index.html and have it write to console.

@jrowny Is right though. Third party plugins and Angular don’t play nicely together in general. You basically need to rewrite them or wrap them inside directives. Search on “angularjs jquery plugin”. You’ll find lots of examples on how to do this.