Hi, I’m struggling to find an example of how to (cleanly) access the route parameter that is defined on the parent route.
say we have a module named “spot”:
@route({
routes: [
{ id: 'data', path: 'data/:channel', component: () => SingleChart },
{ id: 'export', path: ['', 'data/export'], component: () => ExportData }
]
})
export class Spot {
id: string;
spot: GetSpotResponse;
async canLoad(params: { id: string }) {
this.id = params.id;
this.spot = await getApiSpotId({ path: { id: this.id } });
}
}
now, the module is registered in the parent router:
{ id: ‘spot’, path: ‘spot/:id’, component: () => Spot },
the question is - how to cleanly access the “id” of the spot, in a component such as ExportData.
async loading(params: {}, current: RouteNode) {
this.id = current.context.parent.node.params.id;
or maybe inject the Spot object and read from there? What is the suggested approach?
TIA.