Created
November 10, 2018 09:09
-
-
Save Muzammil-Bilwani/43fcc901f9aee27f2295369377203736 to your computer and use it in GitHub Desktop.
Title of routing page using angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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