Nikitha
Nikitha

Reputation: 9

Using component from parent module inside of child modules

In my Angular project, I am trying to use a component from a shared module where its child component is imported in the Dashboard module but facing this error.

  1. If app-send-email is an Angular component, then verify that it is part of this module.
  2. If 'app-send-email' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

app.routing.ts

const routes = [
{ 
    path: 'dashboard',
    loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule)
}]

dashboard.module.ts

    import { SendEmailComponent } from './shared/send-email.component';
    import { SharedDialogComponentModule } from '../shared/shared-dialog-component.module';
    @NgModule({
imports: [SharedDialogComponentModule],
      declarations: [ RecruiterSendEmailComponent ]
    });

shared-dialog-component.module.ts

import { EmailDialogComponent } from '../../dashboard/shared/template/dialog/email-dialog/email-dialog.component';
@NgModule({
  declarations: [EmailDialogComponent],
  entryComponents: [EmailDialogComponent],
  exports: [EmailDialogComponent]
})

email-dialog.component.html

<app-send-email></app-send-email>

Can anyone please help with this issue?

Upvotes: 0

Views: 589

Answers (1)

Shashank Vivek
Shashank Vivek

Reputation: 17494

Well, you need to import the module SharedDialogComponentModule

import { SendEmailComponent } from './shared/send-email.component';
import { SharedDialogComponentModule } from '../shared/shared-dialog-component.module';
@NgModule({
  import: [ SharedDialogComponentModule ]
  declarations: [ RecruiterSendEmailComponent ]
});

Upvotes: 1

Related Questions