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

500 Views Asked by At

Tried with these approachesI 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>
1

There are 1 best solutions below

0
On

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'.