简体   繁体   中英

Not able to include header component in user module build upon lazy load concept

Tried with these approaches I have created a component called header which includes the navigation. User is a module which includes a user-list and user-details component which is implemented by the lazy load technique. Along with user, i have created the Home component and Dashboard component. I am able to redirect to Home and Dashboard pages but not to the User page, where I have added the header component() in all of the component. Below is the header when I try to redirect to user page:

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>

You need to create module for header component. You can create it with cli using this command:

ng g module header --flat

In 'header.module' you need to declare HeaderComponent in declarations array and export it in exports array. and add 'header.module' in imports array of 'app.module.ts'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM