2

I have a dashboard route in my Angular 2 App which has few child routes.

{ path: 'app/:property', component: DashboardComponent, canActivate: [AuthGuardService], 
  children: [
    { path: 'home', component: HomeComponent }
    { path: 'welcome-slide', component: WelcomeSlideComponent }
    { path: 'analytics', component: AnalyticsComponent }
  ]
},

Is there a way for me to get a list of the child routes with their path (and maybe also a name) which I can then use them to populate my navigation bar with them ?

user2125726
  • 127
  • 2
  • 10

1 Answers1

2
this.router.config

Routes don't have a name though, but the other information is available.

See also https://angular.io/docs/ts/latest/api/router/index/Routes-type-alias.html

Using router.routerState you can also iterate parent and child routers to get the routes from them.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567