I am working on a semi-big project and I wanted to split it in modules. The problem is that i can't access the routes of admin.module.ts. So in the app.module I have imported the admin Module
imports: [
BrowserModule,
CommonModule,
AppRoutingModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
NgSelectModule,
AdminModule,
SharedModule
],
my routing module does not have the admin route in my admin.module.ts. The ngModule in admin.module looks like this
@NgModule({
declarations: [
AdminComponent,
AdminLandingComponent
], imports: [
CommonModule,
AdminRoutingModule
]
})
and the routes in the admin-routing.module.ts look like this
{ path: 'admin', component: AdminComponent, children: [
{ path: '', component: AdminLandingComponent }
]}
I use forChild() so that is not the problem When i try to access localhost:4200/admin i get redirected to page not-found. Why does it happen? How to fix it?
full files
- parent module - app module
- main routes - app-routing module
- submodule - admin module
- child routes - admin-routing module
admin-routing.module.tsusing something likeexport const AdminRoutingModule = RouterModule.forChild(routes);? - Sonu KapoorloadChildrenin app-routing.module.ts{ path: 'admin', loadChildren: () => AdminModule },(don't forget to import it in this file) - Maksym Shevchenko@NgModule({ declarations: [ AdminComponent, AdminLandingComponent ], imports: [ CommonModule, AdminRoutingModule ], exports: [ AdminRoutingModule ] })- Matt McNabb