I have a root component and want to display route title inside special section in it.
I can detect which route is active in every component.
However, I don`t know how to do it inside root component.
This code shows title fine in ChildComponent1 :
route:ActivatedRoute
ngOnInit() {
this.route.data.subscribe(
data => console.log(data)
)
}
How can I detect what is current route`s title and display it inside the root component?
export const routes: Routes = [
{path: '', component: Component1, canActivate: [NonAuthGuard]},
{
path: 'root', component: rootcomponent, canActivate: [AuthGuard], children: [
{
path: 'Child1',
component: ChildComponent1,
data: {
title: 'Child1'
},
canActivate: [AuthGuard],
canDeactivate: [CanDeactivateGuard]
},
{
path: 'Child2',
component: ChildComponent2,
data: {
title: 'Child2'
},
canActivate: [AuthGuard],
canDeactivate: [CanDeactivateGuard]
},
]}