ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

code breaking after moving from 0.5.0 to 1.0.9 version #379

Open jaspreetsinghmadan opened 7 years ago

jaspreetsinghmadan commented 7 years ago

In my application i was using ocLazyLoad.load(name: RequiredModule,files: []).then(function () { } to load modules. But when i move to 1.0.9 load function started throwing error "no file to load has been found, if you're trying to load an existing module you should use the 'inject' method instead of 'load'.

so i modified the code to use inject ocLazyLoad.inject(name: RequiredModule,files: []).then(function () { } but i am getting unknown provider error. like I am loading module A which is dependent of module B. And while loading module A service in module B is throwing unknown provider error. The same code is working with load function of 0.5.0. Please suggest what am i missing.

vasuneet commented 7 years ago

Let me add some more information. Able to resolve the issue with 1.0.9 when we inject along with all dependent module. Let me explain as below : A module is dependent on B in 0.5 i was able to get injector using following code - angular.injector(['ng','A'); But in 1.0.9 it is not working and saying injector is not able to resolve xxx service from B module. if i do the following change it starts working - angular.injector(['ng','B','A']);

vasuneet commented 7 years ago

Any update on this?

vasuneet commented 7 years ago

I think this is the related issue (chaining dependency resolving) which is mentioned in the following : https://github.com/ocombe/ocLazyLoad/issues/198 https://github.com/ocombe/ocLazyLoad/issues/214

thomasraynal commented 7 years ago

This occured since 0.6.0. As workarounds, either use requirejs or define the module and its dependencies before loading the file (I'm looking for several plugins container, so that work for me).