You have two options here:
1. You can access parent resolve data via the child’s resolver by creating a child-specific resolver and accessing the route’s parent property.
[…module.ts | …component.ts]
{
path: 'project/:projectId',
component: ProjectDetailComponent,
resolve: { project: ProjectResolver }
children: [
{
path: ':projectId/edit',
component: EditProjectComponent,
resolve: { edit: EditProjectResolve }
}
]
}
edit-project-component.ts
ngOnInit() {
this.edit = this.route.snapshot.data.edit;
}
2. You can bypass the child’s resolver all together and access parent data from within the child component.
[…module.ts | …component.ts]
{
path: 'project/:projectId',
component: ProjectDetailComponent,
resolve: { project: ProjectResolver }
children: [
{
path: ':projectId/edit',
component: EditProjectComponent
}
]
}
edit-project-component.ts
ngOnInit() {
this.route.parent.data
.subscribe((data) => {
this.edit = data.edit;
});
}