ocombe / ocLazyLoad

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

Thank you #419

Closed anurbol closed 5 years ago

anurbol commented 6 years ago

At first I was confused by "not totally perfect" documentation and long service name, and strange api, and not loading es6 modules, and nightmare source code. And I called the library shit. But now, when I finally got this to work, despite that problem with es6 modules, I realise what a genius you are, the Author! Thank you, Thank you, Thank you thousand times!!!

BTW, if someone else tries to lazy-load es6 modules: import('path/to/your/module').then( () => { $ocLazyLoad.inject('nameOfAngularModule') } )

Aaron-Pool commented 5 years ago

Just to add some information to the pool here, the safest thing for us seems to be:

$ocLazyLoad.toggleWatch(true);
importModule()
  .then(() => $ocLazyLoad.inject(module))
  .then(() => {
    $ocLazyLoad.toggleWatch(false);
    deferredModule.resolve($state.get(name));
  });

Because, if you don't toggle module watch on and off, we found that new (as in not required by any modules that were loaded in the initial load) third party module dependencies aren't always instantiated correctly.