Getting below error when I am putting routing config details in a different ts file. However it works fine if I put the route config in boot.ts file.
Unhandled Promise rejection: Component DashboardComponent is not part of any NgModule or the module has not been imported into your module. ; Zone: ; Task: Promise.then ; Value: Error: Component DashboardComponent is not part of any NgModule or the module has not been imported into your module.
app.routing.ts:
import { ModuleWithProviders } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { DashboardComponent } from './Components/dashboard/dashboard.component';
const appRoutes: Routes = [
{ path: '', redirectTo: 'Dashboard', pathMatch: 'full' },
{ path: 'Dashboard', component: DashboardComponent },
];
export const AppRouting = RouterModule.forRoot(appRoutes, {
enableTracing: true
});
boot.ts
//other imports
import { AppRouting } from './app.routing';
@NgModule({
imports: [BrowserModule,
//AppRouting,
RouterModule.forRoot(appRoutes, { enableTracing: true }), // <-- debugging purposes only
AgGridModule.forRoot(),
MaterialModule,
SlimLoadingBarModule.forRoot(),
ToastyModule.forRoot(),
BrowserAnimationsModule, FormsModule,
HttpModule, TreeModule, GrowlModule, FileUploadModule, InputTextModule, ButtonModule, ConfirmDialogModule, NgxChartsModule
, AgmCoreModule.forRoot({ apiKey: 'AIzaSyC9TWEHsjWT_QX_Rxl8VXtnnY582aY4mBQ' }) //Angular Google Map Setup
],
providers: [BaseComponentService, TreeNodeService, LowryToastyService],
declarations: [APP_COMPONENTS],
entryComponents: [ENTRY_COMPONENTS],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { }
You haven't declare "DashboardComponent" in app.module.ts put this in your app.module.ts