为 loadChildren 提供一个函数有什么好处?

What is the benefit of providing a function to loadChildren?

作者在文章Understanding Modules and Services中说:

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:

这是代码:

//Within contacs.module.ts
//Doesn't it need an export?
function contactsEntryPoint() {
    return ContactsModule();
}

//Within the app-routing.module.ts
{
    path: 'contacts',
    loadChildren: contactsEntryPoint
}

有人明白这是想说明什么吗?

这是设置延迟加载的代码;但是程序 实际上 急切加载模块。

这样做的原因(如前所述)是为了确保您没有任何模块间依赖性(尤其是单例提供程序!)。