Skip to content

Instantly share code, notes, and snippets.

@Muzammil-Bilwani
Created November 10, 2018 09:09
Show Gist options
  • Save Muzammil-Bilwani/43fcc901f9aee27f2295369377203736 to your computer and use it in GitHub Desktop.
Save Muzammil-Bilwani/43fcc901f9aee27f2295369377203736 to your computer and use it in GitHub Desktop.
Title of routing page using angular
this._router.events.pipe(
filter((event) => event instanceof NavigationEnd)
, map(() => this.activatedRoute)
, map((route) => {
while (route.firstChild) route = route.firstChild;
return route;
})).pipe(
filter((route) => route.outlet === 'primary')
, mergeMap((route) => route.data))
.subscribe((event) => this.title = event.title);
const routes: Routes = [{
path: 'calendar',
component: CalendarComponent,
children: [
{ path: '', redirectTo: 'new', pathMatch: 'full' },
{ path: 'all', component: CalendarListComponent, data: { title: 'My Calendar' } },
{ path: 'new', component: CalendarEventComponent, data: { title: 'New Calendar Entry' } },
{ path: ':id', component: CalendarEventComponent, data: { title: 'Calendar Entry' } }
]
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment