Angular 是否在父模块中使用延迟加载的组件?

Angular 是否在父模块中使用延迟加载的组件?,angular,angular5,Angular,Angular5,我有一个父模块(app.module)和一个子模块(contacts.module)。子模块是延迟加载的。父模块利用子模块中的组件,但当我导航到子路由时,会出现错误: 'app-contacts-home' is not a known element: 1. If 'app-contacts-home' is an Angular component, then verify that it is part of this module. 2. If 'app-contacts-home' i

我有一个父模块(app.module)和一个子模块(contacts.module)。子模块是延迟加载的。父模块利用子模块中的组件,但当我导航到子路由时,会出现错误:

'app-contacts-home' is not a known element:
1. If 'app-contacts-home' is an Angular component, then verify that it is part of this module.
2. If 'app-contacts-home' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to 
显然,该组件不是父模块的一部分,因为它是延迟加载的。我尝试在contacts.module中添加
app contacts home
作为
entryComponent
,但没有成功


如何在父组件中使用延迟加载的组件

不,您不能在父模块中使用子延迟加载模块中的组件

在这些情况下,您应该做的是创建第三个模块(SharedModule),该模块将包含在两个模块的组件中使用的组件。然后在父模块和子模块中导入第三个模块,第三个模块不会被延迟加载

本页中的文档包含有关这方面的有用信息

希望这有帮助