Open luncht1me opened 7 years ago
IMO, Because this is an Angular module, serie: true
should be the default behavior. Since the order that files are loaded is pretty important in Angular, especially if you have entire modules that consist of services, controllers, and app config blocks / router states that you want to lazyload.
I'm having some serious trouble with ocLazyLoad 1.0.9 w/ Angular 1.6.3 and ui-router 1.0.0-rc.1.
I have an admin module which is all my admin js files for angular that get loaded if the current authenticated user is an admin.
It works.... some of the time. On my main app.js on the very base state is where the check happens in a deferred resolve to determine if admin files should be loaded or not. Then, in a child state, this resolve is an injected dependency so it waits on the base resolve to return before loading in the state.
From what I can see, the chain is flowing as intended. But, ocLazyLoad simply fails to load controllers sometimes.
Every now and again (say.... 1/5 times) when I refresh my admin states, I get the error:
Error: [$controller:ctrlreg] The controller with the name 'AdminRootCtrl' is not registered.
And sure enough, in the ocLazyLoad debug logs, there is noAdminRootCtrl
.BUT! The file in which the controller resides, is loaded, as evident in an earlier log from ocLazyLoad:
ocLazyLoad.fileLoaded modules\admin\client\js\controllers\dashboard.js
.dashboard.js
has theAdminRootCtrl
controller within it. It just simply isn't loading the component from the file randomly, despite ocLazyLoad saying it's loaded the file.My ui-router uses
resolvePolicy: { when: "EAGER", async: "WAIT" },
Help?
EDIT:
Turns out just had to use
serie: true
to ensure loading order...