Issue Overview:
In my Angular application, I have multiple modules structured like this:
angular.module('app', ['app.core', 'app.views']); // not lazy load
Each module under app.views
utilizes a RouterUtil to define their own routes using:
$stateProvider.state('state name', {/* some configs here */});
The RouterUtil also includes a method to access all registered states, which is used to generate a dynamic menu.
I am incorporating the ocLazyLoad library for lazy loading external modules. When the page loads, ocLazyLoad makes a request for additional JavaScript files containing angular modules, which are then added to the current environment.
An issue arises when attempting to refresh a page on an external module:
Current Behavior:
- Angular registers $states
- ocLazyLoad initiates a request for the external module
- ui-router attempts to parse the URL and redirects to default page as it cannot find a matching state
- After ocLazyLoad finishes adding new modules, the requested URL now has a corresponding state
Is there a way to make ui-router wait for the ocLazyLoad request before checking if a URL is registered?