Im getting this error but I don't know why, since this core module is being imported only once
The code App.Module
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
AppRoutingModule,
SharedModule,
CoreModule
],
providers: [
DataService,
AuthService,
ShoppingCartService,
ProductService,
HttpClientModule
The appRouting:
const adminModule = ()=> import('./admin/admin.module').then(m=>m.AdminModule);
const coreModule = ()=> import('./core/core.module').then(c=>c.CoreModule);
const routes: Routes = [
{
path: '', component:ShellComponent,
children: [
{path: 'detail/:id', component: DetailComponent},
{path: 'admin', loadChildren:adminModule},
{path: 'home', loadChildren:coreModule},
]
},
{path: 'login', component: LoginComponent},
{path:'edit/:id', component:RegisterComponent},
{path:'register', component: RegisterComponent}
];
I get this error when I navigate to home page, as I have this constructor in the core module
@NgModule({
declarations: [
MoviesComponent,
DetailNoRoutingComponent,
HomeComponent,
ProductCardComponent,
ProductFilterComponent
],
imports: [
SharedModule,
coreRoutingModule
]
})
export class CoreModule {
constructor( @Optional() @SkipSelf() parentModule: CoreModule) {
if (parentModule) {
throw new Error('CoreModule has already been loaded. You should only import Core modules in the AppModule only.');
}
}
Can anyone help me out? Im not understanding whats goin on, maybe something Im missing in the imports or the logic is messed up