简体   繁体   中英

Angular2 lazy loaded event

I am using lazy loading with Angular2 and the PreloadAllStrategy .

I'm just wondering, is there any way to detect when all modules are preloaded and to preform an action when everything is preloaded?

I imagined there would be a router event similar to NavigationStart for this, such as RouteLoaded, but there is not.

Any ideas how this can be done?

The solution is to implement a SelectivePreloadingStrategy and to inject it to the component that needs to detect when a module is lazy loaded. This is described in the guide:

https://angular.io/docs/ts/latest/guide/router.html#!#preloading

update Related Angular issue https://github.com/angular/angular/issues/14036

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM