I am declaring my routes typically like this:
{
path: 'datasel/:datasel',
component: aComponent,
resolve: { model: AWATranslationLoaderResolver },
data: { resolvedata: 'Assets', reuse: true },
}
Is it possible to add some writable data to a route? My idea is to modify that data in aComponent so the reuse strategy would know about some important events happening in the component.
Something like this would be nice to have in component:
this.router.events.subscribe(ev => {
if (ev instanceof ActivationEnd &&
Object.is(ev?.snapshot?.component, aComponent)) {
ev.snapshot.customData.inportantEvent = true;
}
});
and then read that data in the custom reuse class:
shouldAttach(route: ActivatedRouteSnapshot): boolean {
console.log(route.customData.importantEvent);
return !!this.handlers[this.getUrl(route)];
}
1