I have set up my layout as shown below. I would like to have my components (each being a separate route) displayed inside mat-card-content. The issue arises when I try to dynamically change mat-card-title, as it is not within the router-outlet and does not receive any data. Is there a way to accomplish this without having to include mat-card-header in each component?
<mat-card>
<mat-card-header>
<mat-card-title>{{ routerTitle }}</mat-card-title>
<span>
here I want to have my router data
</span>
</mat-card-header>
<mat-card-content>
<router-outlet></router-outlet>
</mat-card-content>
</mat-card>
Below is how my module routes are configured:
{ path: 'dashboard', component: DashboardComponent, data: { title: 'Dashboard' } }
Here is the main app-routing configuration:
{
path: '',
component: PanelLayoutComponent,
children: [
{
path: '',
loadChildren: () =>
import('./modules/modules.module').then(
(module) => module.ModulesModule
),
},
],
},
After logging router.snapshot.data.title
in the parent component, an empty object is returned since it is outside of the router-outlet.