With the new RC4-Router (3.0.0-beta.2) from Angular2, I have the following Route-Setup:
export const Routes: RouterConfig = [
{
path: 'account',
pathMatch: 'prefix',
canActivate: [
AppAuthGuard
],
children: [
{
path: 'create',
component: AccountRegistration,
data: {
'title': 'Create an Account'
}
},
{
path: 'login',
component: AccountLogin,
data: {
'title': 'Log into your Account'
}
}
]
}
];
You can open routes. But I have a global service, which should set the title in the AppComponent from the "title" - properties of the properties of the "data" routes. So I sign router.events-Observable:
this.router.events.subscribe(value => {
if (value instanceof NavigationEnd) {
console.log(this.router.routerState.snapshot.root.data['title']);
}
}
But getting the title is simply impossible. Is this possible, and should I be able to get route information? Does anyone have an example for me?
source
share