Answer the question
In order to leave comments, you need to log in
How to use a component of one module in another?
Good afternoon. I am making a Notification module. I made a component for showing notifications and made a NotificationBellComponent component that will display an icon in the ToolbarComponent. In the NotificationModule module, I made an export
@NgModule({
imports: [CommonModule, SharedModule],
declarations: [NotificationComponent],
exports: [NotificationComponent,NotificationBellComponent],
providers: [NotificationService]
})
. In the ToolbaModule did@NgModule({
imports: [CommonModule, SharedModule, NotificationModule,NotificationBellComponent],
declarations: [ToolbarComponent,NotificationBellComponent],
exports: [ToolbarComponent]
})
<sd-notification-bell></sd-notification-bell>
zone.js?1476075322482:355 Unhandled Promise rejection: Template parse errors:
'sd-notification-bell' is not a known element:
1. If 'sd-notification-bell' is an Angular component, then verify that it is part of this module.
Answer the question
In order to leave comments, you need to log in
NotificationModule
You need to be sure to declare NotificationBellComponent
in an declarations
array
@NgModule({
imports: [CommonModule, SharedModule],
declarations: [NotificationComponent, NotificationBellComponent],
exports: [NotificationComponent, NotificationBellComponent],
providers: [NotificationService]
})
NotificationModule
@NgModule({
imports: [CommonModule, SharedModule, NotificationModule],
declarations: [ToolbarComponent],
exports: [ToolbarComponent]
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question