0

I have a file "A.js" in which I have a initialised a module as given below

angular.module("x", []);

I have another file "B.js" in which also I have initialised a module as give below, in this case it is dependent on the "x" module as defined above in A.js

angular.module("y", ["x"]);

Now in the html file I have declared the script files as given below -

<script src = "B.js" ></script>
<script src = "A.js" ></script>

On loading the application, I am getting below error -

"Uncaught Error: [$injector:unpr] ..."

Question - Is the above error because the sequence in the HTML file should have been, first load A.js and then B.js since "y" module in B.js is dependent on "x" module in A.js?

Note - I have checked all the other probable places which could have caused the error, they are all fine. I am left with the above question only.

9
  • how do you instantiate your app? Commented Sep 9, 2015 at 14:20
  • yes, the order in which you have the script tags matters. Commented Sep 9, 2015 at 14:21
  • @Girafa - using ng-app in the html file Commented Sep 9, 2015 at 14:29
  • @Davin Tyron - So you are telling the error which is a DI error could be or is caused because of the above script tags? Commented Sep 9, 2015 at 14:30
  • you can try deferring application instantiation by manual bootstrap on dom ready for example. Commented Sep 9, 2015 at 14:32

0

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.