In Angular 4, I import a library from node modules that has specific routes, for example:
const appRoutes: Routes = [
{
path: 'section/:sectionId',
component: SectionIndexComponent,
children: [
{
path: ':dashboardId',
component: DashboardComponent,
},
{
path: ':dashboardId/:dashboardParam',
component: DashboardComponent,
},
]
},
{
path: '',
component: AppIndexComponent
},
{
path: '**', component: PageNotFoundComponent
},
];
@NgModule({
imports: [RouterModule.forRoot(appRoutes)],
exports: [RouterModule],
})
export class AppRoutingModule { }
In the consumption project, I need to redefine / redirect one of the routes, for example:
const appRoutes: Routes = [
{
path: '',
redirectTo: '/section/landing/main',
pathMatch: 'full'
}
];
@NgModule({
imports: [RouterModule.forChild(appRoutes)],
exports: [RouterModule],
})
export class RoutingModule { }
The path I'm trying to override is the '' (root) path that is routed to the AppIndexComponent. In the application for consumption, I need it to be directed to "/ section / landing / main".
Routing in a consumer application does not seem to redefine the route. I tried changing the import order. I'm not sure if this will work that way, or if there is anything else, in particular, what should I do.
How can I redefine and redirect a route from a repo imported into another project?