Reputation: 81
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
Upvotes: 3
Views: 420
Reputation: 2109
Lazy loading should happen at an application and not a library level
From this disscussion: article link
Upvotes: 0