无法在延迟加载概念

时间:2017-09-14 11:22:52

标签: angular lazy-loading angular-cli angular2-components angular2-modules

Tried with these approaches我创建了一个名为header的组件,其中包含导航。用户是包含用户列表和用户详细信息组件的模块,该组件由延迟加载技术实现。与用户一起,我创建了Home组件和Dashboard组件。我可以重定向到Home和Dashboard页面,但不能重定向到User页面,我在所有组件中添加了header component()。当我尝试重定向到用户页面时,下面是标题:

core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: Template parse errors:
'app-header' is not a known element:
1. If 'app-header' is an Angular component, then verify that it is part of this module.
2. If 'app-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<app-header></app-header>
<h2>Users</h2>
<router-outlet></router-outlet>

1 个答案:

答案 0 :(得分:0)

您需要为标头组件创建模块。您可以使用以下命令使用cli创建它:

ng g module header --flat

在&#39; header.module&#39;您需要在HeaderComponent数组中声明declarations并将其导出到exports数组中。并添加&#39; header.module&#39;在imports数组&#39; app.module.ts&#39;。

相关问题