[英]What is the benefit of providing a function to loadChildren?
In the article Understanding Modules and Services the author says: 在“ 理解模块和服务”一文中 ,作者说:
if you organized your modules this way, you can still use the loadChildren keyword without actually Lazy Loading the module, as a proof that your module is independent and well-structured:
如果以这种方式组织模块,则仍然可以使用loadChildren关键字,而无需实际延迟加载模块,以证明模块是独立且结构良好的:
This is the code: 这是代码:
//Within contacs.module.ts
//Doesn't it need an export?
function contactsEntryPoint() {
return ContactsModule();
}
//Within the app-routing.module.ts
{
path: 'contacts',
loadChildren: contactsEntryPoint
}
Does anyone understand what this is trying to illustrate? 有人知道这试图说明什么吗?
This is setting up the code for lazy-loading; 这是在设置延迟加载代码; but the program actually eager-loads the module.
但是程序实际上渴望加载模块。
The reason for doing so (as presented), is to ensure that you don't have any inter-module dependencies (especially singleton providers!). 这样做的原因(如前所述)是为了确保您没有任何模块间依赖性(尤其是单例提供者!)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.