简体   繁体   中英

How to load Angular library which contains lazy modules dynamic?

I am trying to do like this:

Usually we add a lazy module like this in routing.ts,

{ path: 'taskCenter', loadChildren: './taskCenter/taskCerter.module#TaskCenterModule' },

now,I want to loadChildren Dynamic from an package which is produced by rollup or ng-packagr !! Dynamic!

eg:after Aot build,when url is 'localhost:4200/#/taskCenter',it will dynamic load taskCenter.umd.js and it's child modules from assets folder

First,how can we package all lazy modules in library? Then,how to load this module dynamic?

 // First, in Library ,how to package all code including TestChildrenModule @NgModule({ imports: [ RouterModule.forChild([ { path: '', pathMatch: 'full', component: ModuleaComponent }, { path: 'aa', loadChildren: './test-children/test-children.module#TestChildrenModule' } ]) ], declarations: [ModuleaComponent], exports: [ModuleaComponent] }) export class ModuleaModule { }

this link maybe can help: https://github.com/lmeijdam/angular-umd-dynamic-example

Lazy loading should happen at an application and not a library level

From this disscussion: article link

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