2

In my app I have ui-router set up, and in one particular state i.e. "MAP" I want to load a 3rd party Javascript file.

Right now I have it as part of my Index.html at the bottom of the page. But i thought it would be better practice to only load this in view which needs it.

What is the best way to include this script in only specific partial views ?

1
  • Incredible - I was just about to ask the same question! Commented Dec 17, 2014 at 20:36

1 Answer 1

1

Turns out you can simply include the <script> tag in your partial. Works perfectly fine for me.

Also, if you have a window.onload function, you can replace it with a self invoking function like

(function(param){
     alert("partial running");
     bla bla....
})();

so it will run when the partial is pulled up.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.