Forum


HomeHomePremiumPremiumDevelopmentDevelopmentOrder On Page Causes Angular Module to FailOrder On Page Causes Angular Module to Fail
Previous
 
Next
New Post
7/31/2015 11:37 AM
 

Hello,

I have three angular modules. This is not the first time I've had multiple on the same page but this time I'm having issues. When the modules are in a certain order the top one gives me and error. However if I move said module to the bottom of the page the errors go away. What's going on? The first of the modules created and uploaded is the one giving me problems.

 

This is what happens if I move it up:

 

 

The error message and link:

http://errors.angularjs.org/1.4.3/$injector/nomod?p0=app

https://docs.angularjs.org/error/$injector/unpr?p0=HhDnnApiProvider%20%3C-%20HhDnnApi%20%3C-%20WelcomeCtrl

Thanks in advance.

 
New Post
8/3/2015 5:36 AM
 

Hello again,

I've been poking around with the module having issues. The only difference between it and the other two is that it includes two script files instead of just one. It appears that the two scripts are unable to find each other depending on their position on the page specifically l6_zone30 which is where all three have been placed. This is very odd behavior as they all work fine together but only in a certain order. I've been researching module load order but haven't found anything of use. The idea was to manually set which one loads first. My module id's are 500, 496, and 499 500 being the problem child. I seem to have been able to fix the problem by removing the second script and placing all the code in a single js file for each module. Now this works for now as these are very small modules and larger ones would probably have their own pages. However I'd like to figure out what is causing this issue in the first place. I like the idea of splitting my code into their own scripts for maintainability.

Thanks.

 
New Post
8/3/2015 10:38 AM
 

And I figured out what I was doing wrong. I had defined my angular module wrong. I was making a basic mistake and naming my second js file the same name as my main app. I was under the impression that I was passing the app to the factory as a reference. I'm unsure why this only caused issues depending on its position on the page but my thought is that I was both causing and fixing my problem at the same time. Since all three dnn modules referenced a js file where my factory was stored at least one of them was loading onto the page correctly where it was linked to my app. I believe depending on the order on my page the dnn modules where loading where causing it to either find or over-write the factory.

I also learned something. Since all three dnn modules use the same factory I only need to pass that js file once to the page and all three modules can reference it as long as the one that registers it exists on the page. Two less scripts the user has to download.

Thanks.

 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentOrder On Page Causes Angular Module to FailOrder On Page Causes Angular Module to Fail



Try FREE
30 days money back guaranteed