I have a route config as following:
export const ProjectRoutes: Route[] = [
{
path: 'projects',
component: ProjectComponent,
canActivate: [ScrollTop, AuthGuard],
data: {
roles: [Role.USER]
}
},
{
path: 'project/:id',
component: ProjectDetailsComponent,
children: [
{
path: '',
component: ProjectInfoComponent,
canActivate: [ScrollTop, AuthGuard],
data: {
roles: [Role.USER]
}
},
{
path: 'tools',
component: ProjectToolsComponent,
canActivate: [ScrollTop, AuthGuard],
data: {
roles: [Role.USER]
}
}
]
}
];
Where the template of ProjectComponent is:
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<priz-project-nav [project]="project"></priz-project-nav>
</div>
<div class="col-md-10">
<router-outlet></router-outlet>
</div>
</div>
</div>
Now, as you can see, the priz-project-nav
requires a project to render the navigation, but also ProjectInfoComponent
and ProjectToolsComponent
do.
So, what I am forced to do now is to load project
object in each component separately, including in the parent one.
My question is, is it possible to pass loaded once object between components while each and every one of the child components is set under it's own route?