I wanted to delete the routing files and import them directly into the modules but it only worked for forRoot()
me forChild()
overwriting the routes forRoot()
could someone tell me why or how I could do it
features.module.ts
const routes: Routes = [
{
path: '',
component:ManualComponent,
data:{"permi":"todo"}
},
{
path: 'menu',
component:MenuComponent
},
{
path: 'settings',
component:SettingsComponent
}
];
@NgModule({
declarations: ...,
imports: [
CommonModule,
ReactiveFormsModule,
FormsModule,
SharedModule,
MDBBootstrapModule.forRoot(),
RouterModule.forChild(routes) // esta linea me esta sobrescribiendo las rutas
]
})
export class FeaturesModule { }
app.module.ts
const routes: Routes = [
{
path: '', component: HomeComponent, canActivate: [AuthGuard],
//loadChildren: () => import('./features/features.module').then(m => m.FeaturesModule)
},
{
path: 'login',
component: LoginComponent
}
];
@NgModule({
declarations: [
AppComponent,
HomeComponent,
LoginComponent
],
imports: [
ReactiveFormsModule,
FormsModule,
BrowserModule,
RouterModule.forRoot(routes),// importo los routes
CoreModule,
FeaturesModule,// importo el modulo de feactures
SharedModule
],
bootstrap: [AppComponent]
})
export class AppModule { }
comment out the loadChildren
in app.module.ts to see if this was the problem, but it's not
You don't need to re-import the features module. You are already doing it in lazy loading. When you import it you are also bringing all its routes, that's why they are overwritten.