Closed anurbol closed 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.
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') } )