Reputation: 1
I need to use my sidebar component in my module in angular 10 but its throwing me a error while i use selector of component inside my module 'app-sidebar' is not a known element: src/app/library/library-home/library-home.component.html:2:3 - error NG8001: 'app-sidebar' is not a known element: 1. If 'app-sidebar' is an Angular component, then verify that it is part of this module. 2. If 'app-sidebar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
what i did first i export my sidebar component exports: [SidebarComponent]
after inside my module import {SidebarComponent} from '../sidebar/sidebar.component';
and putting in imports: [SidebarComponent]
Upvotes: 0
Views: 742
Reputation: 19
Add to your SidebarModule
:
exports: [SidebarComponent]
After that, import it to your LibraryModule
. It should look something like this:
imports: [SidebarModule]
Upvotes: 2
Reputation: 11
If you want to use the component in your module, you have to declare it.
@NgModule({
declarations: [SidebarComponent]
});
export class HomeModule {}
You don't need to export the component for it to work.
Upvotes: 0