简体   繁体   English

向loadChildren提供功能的好处是什么?

[英]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.

相关问题 在JavaScript中使用(function(){...})()有什么好处 - What is benefit of using (function(){…})() in JavaScript 在javascript中的函数声明中命名函数的好处是什么? - What is the benefit of naming a function in a function declaration in javascript? loadChildren语法 - 什么是哈希部分 - loadChildren syntax - what is hash part 使用lodash分配功能有什么好处? - What is the benefit of using lodash assign function? 内联函数调用有什么好处? - What's the benefit of inline function calls? 将async预先添加到返回promise的函数有什么好处? - What is the benefit of prepending async to a function that returns a promise? 将函数返回函数会立即给出什么好处? - What benefit does returning a function to a function immediately give? 与返回函数(咖喱)的处理程序函数反应 - 使用它有什么好处? - React with a handler function that returns a function (a curried) - what's the benefit of using it? Javascript:使用函数上下文与传递作为参数有什么好处 - Javascript: What is the benefit of using function context vs passing as parameter 将函数结果分配给变量与调用内联有什么好处? - What are the benefit of assigning function results to variables vs calling inline?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM