I have a series of Angular components in the structure as follows.
- RootComponent --> Contains router-outlet
- Child component ->
contains router-outlet
- Grand child component -> Contains a button to trigger a navigation back to the root component
- Child component ->
contains router-outlet
My question is from a routerLink on a button in the grandchild component how do I navigate to the rootcomponent?
app-routes
const routes: Routes = [
{
path: '',
redirectTo: environment.devRedirect,
pathMatch: 'full',
canActivate: [AuthenticationGuard]
},
{
path: 'customers/:customerId/contracts/:contractId',
canActivate: [AuthenticationGuard],
children: [
{
path: 'projects/:projectId/grouping',
loadChildren: './grouping/grouping-routing.module#GroupingRoutingModule',
data: { animation: 'grouping' },
canActivate: [ AuthenticationGuard ]
},
{
path: '',
loadChildren: './projects/projects-routing.module#ProjectOverviewRoutingModule',
data: {
animation: 'project-overview'
},
canActivate: [ AuthenticationGuard ],
},
]
}
];
child component routes
const routes: Routes = [
{
path: '',
component: GroupingComponent,
canActivate: [ AuthenticationGuard ],
children: [
{
path: 'create',
component: CreateEditComponent,
data: { animation: 'create' },
canActivate: [ AuthenticationGuard ]
},
{
path: ':groupId/edit',
component: CreateEditComponent,
data: { animation: 'edit' },
canActivate: [ AuthenticationGuard ]
},
{
path: '',
component: OverviewComponent,
data: { animation: 'overview' },
canActivate: [ AuthenticationGuard ]
}
]
}
];