0

I have created a shared component which i want to use almost in all the other components, i get this error where it says:

Type BreadcrumbComponent is part of the declarations of 2 modules: BreadcrumbModule and CardsModule!

Here is my breadcrumb.module.ts:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BreadcrumbComponent } from './breadcrumb.component';

@NgModule({
imports: [
    CommonModule
],
declarations: [BreadcrumbComponent],
exports: [BreadcrumbComponent],
})
export class BreadcrumbModule { }

The app.module.ts:

import { BreadcrumbModule } from './shared/breadcrumb/breadcrumb.module';

@NgModule({
imports: [
    BrowserModule,
    BreadcrumbModule,
    AccountsModule,
    CardsModule,
    ....
],
declarations: [AppComponent],
export class AppModule {}

This is the component where i want to use, its already inside declarations:

...
import { BreadcrumbComponent } from '@app/shared/breadcrumb/breadcrumb.component';

@NgModule({
    imports: [CommonModule, CardsRoutingModule],
    declarations: [CardsComponent, BreadcrumbComponent]
})

export class CardsModule {}

1 Answer 1

1

Your CardsModule should import the BreadcrumbModule:

@NgModule({
    imports: [CommonModule, CardsRoutingModule, BreadcrumbModule],
    declarations: [CardsComponent]
})

export class CardsModule {}

Because you added the component to the exports array, it should be available in any module where you import it

Sign up to request clarification or add additional context in comments.

2 Comments

@swordfish that's highly unlikely with the current code you posted. Do you think you can create a stackblitz, showing the issue?
i didn't noticed that the same component already exist in another one, just needed to do the same in that component, every thing is work :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.