Eric Saupe
Eric Saupe's Blog

Eric Saupe's Blog

Adding Extra JavaScript to AngularJS Partials

Eric Saupe's photo
Eric Saupe
·Jan 24, 2014·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

When loading partials into your one page AngularJS app occasionally you'll need to load in JavaScript files that pertain only to those partials. If you are only using AngularJS these added <script> tags won't be rendered by Angular. After Googling for some time I have found that the solution is to load JQuery into your index.html file just before AngularJS. This fixes the problem. partial.html
<script type="text/javascript" src="cdn.someplace.com/file.js"></script>
index.html
<script type="text/javascript" src="code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="ajax.googleapis.com/ajax/libs/angularjs/1.0.."></script>
Problem solved. Hope this helps someone else who runs into the same problem I had. If there is a better, more Angular way, of doing this let me know in the comments below.
 
Share this