javascript - 如何加载包含动态惰性模块的Angular库?
问题描述
我正在尝试这样做:
通常我们在routing.ts中添加这样一个惰性模块,
{路径:'taskCenter',loadChildren:'./taskCenter/taskCerter.module#TaskCenterModule'},
现在,我想从 rollup 或 ng-packagr 生成的包中加载Children Dynamic!动态的!
eg:Aot构建后,当url为'localhost:4200/#/taskCenter'时,会从assets文件夹中动态加载taskCenter.umd.js及其子模块
首先,我们如何将所有惰性模块打包到库中?那么,如何动态加载这个模块呢?
// 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 { }
此链接可能会有所帮助:https ://github.com/lmeijdam/angular-umd-dynamic-example
解决方案
延迟加载应该发生在应用程序而不是库级别
从这个讨论:文章链接
推荐阅读
- tabulator - 制表器可移动行 - 移动到组顶部时 rowPositioning() 不更新(放在组标题上)
- python - 从管理页面隐藏 django-allauth 模型
- c# - 在moq回调c#中设置ref参数
- javascript - 从选择元素中获取超过选项标签的值
- java - 一段时间后,Android Studio java 自动完成功能无法正常工作,并且 Android Studio 项目无法识别某些类
- .net - MSProject 加载项在发布期间不包括 nuget 参考包
- spring-integration - 放慢入站通道
- firebase - 如何解决 facebookauthprovider 中缺少的位置参数?
- azure - 如何用 Powershell 总结 Cores?
- javascript - 如果在 div 中找到,则替换某些文本(仅在最后一行工作)