Skip to content

Instantly share code, notes, and snippets.

@jagomf
Created April 6, 2018 07:59
Show Gist options
  • Save jagomf/bbf9976adb06d8c45bfeec49d0224a09 to your computer and use it in GitHub Desktop.
Save jagomf/bbf9976adb06d8c45bfeec49d0224a09 to your computer and use it in GitHub Desktop.
Nested routes in Angular 2+
...
{ path: 'wall', component: WallHandlerComponent, canActivate: [LoggedGuard],
children: [
{ path: '', redirectTo: 'recent', pathMatch: 'full' },
{ path: 'recent', component: RecentEventsComponent },
{ path: 'ranking', component: RankingUsersComponent }
] },
...
...
<nav mat-tab-nav-bar>
<a mat-tab-link
*ngFor="let link of wallNavLinks"
[routerLink]="link.path"
routerLinkActive #rla="routerLinkActive"
[active]="rla.isActive">
{{link.label}}
</a>
</nav>
<router-outlet name="walloutlet"></router-outlet>
...
...
get wallNavLinks(): { label: string, path: any[] }[] {
return [
{ label: 'Recent', path: 'recent' },
{ label: 'Ranking', path: 'ranking' }
];
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment