Provide information on loaded lazy routes on RouteConfigLoadEnd
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
When accessing modules lazily, RouteConfigLoadEnd gets fired once the factory gets loaded, but before routes are loaded and assigned to route._loadedConfig.
Expected behavior
RouteConfigLoadEnd should be fired after _loadedConfig is assigned, or return routes as a parameter if it’s fired from RouterConfigLoader.
Change proposal:
return map.call(moduleFactory$, (factory: NgModuleFactory<any>) => {
const module = factory.create(parentInjector);
const routes = flatten(module.injector.get(ROUTES));
if (this.onLoadEndListener) {
this.onLoadEndListener(route, routes);
}
return new LoadedRouterConfig(routes, module);
});
What is the motivation / use case for changing the behavior?
Most common use case of RouteConfigLoadEnd is to react once lazy loaded routes are loaded. In localize-router we can use this information for routes localization. However if even is fired before routes are de facto available in _loadedConfig and/or it doesn’t provide this information it makes the entire event unusable as it’s not that different from RouteConfigLoadStart.
Issue is already mentioned here: https://github.com/angular/angular/issues/14036
- Angular version: 4.0.X
-
Browser: all
-
Language: all
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:10 (3 by maintainers)

Top Related StackOverflow Question
@marko999, actually
localize-routerno longer depends on this.With the help from @vsavkin, there is a workaround using
SystemJsNgModuleLoaderthat solves the lazy loading problem and does not require changes in the Router’s code.So unless there are some other interested parties in this feature, this issue can be closed.
@conor-mac-aoidh, @brandonroberts, @johnpapa, are you still interested in having this event as mentioned in #14036?
Maybe extending
SystemJsNgModuleLoaderwould work for you as well?:You can see how it was (mis)used in
localize-routerhere.+1