0

Tried with these approaches我創建了一個名爲頭部的組件,其中包含導航。用戶是一個包含用戶列表和用戶詳細信息組件的模塊,該組件由延遲加載技術實現。與用戶一起,我創建了Home組件和Dashboard組件。我能夠重定向到家庭和儀表板頁面,但不能轉到用戶頁面,我已經在所有組件中添加了頁眉組件()。當我嘗試重定向到用戶頁面時,以下是標題:無法在延遲加載概念的用戶模塊中構建頭部組件

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> 

回答

0

您需要爲標頭組件創建模塊。您可以使用此命令CLI創建:

ng g module header --flat 

在「header.module」你需要在declarations陣列申報HeaderComponent和導出爲exports陣列。並在'app.module.ts'的數組中添加'header.module'。