My routes with data.
const routes: Routes = [
{ path: '', component: HomeComponent, pathMatch: 'full' },
{ path: 'login', component: LoginComponent },
{ path: 'customer', component: CustomerComponent, canActivate: [AuthGuard], data: { title: 'Customer' }, children: [
{ path: 'new', component: CreateCustomerComponent, data: { title: 'New customer' }, canActivate: [AuthGuard]}
]}
];
Get data from active route in component:
this.activeComponent = this.route.snapshot.data.title;
if ( this.route.snapshot.firstChild) {
this.activeComponent = this.route.snapshot.firstChild.data.title;
}
I can't get that child's data title.