Produktbaum Seite bleibt bestehen, auch wenn auf eine andere Seite wie /risikoobjekte gewechselt wird
All checks were successful
Angular Build & Deploy / deploy (push) Successful in 46s

This commit is contained in:
2026-01-07 15:19:30 +01:00
parent 6eaeaaa658
commit 3031a9e10b
4 changed files with 42 additions and 9 deletions

View File

@@ -0,0 +1,31 @@
import { RouteReuseStrategy, ActivatedRouteSnapshot, DetachedRouteHandle } from '@angular/router';
export class CustomRouteReuseStrategy implements RouteReuseStrategy {
private handlers: { [key: string]: DetachedRouteHandle } = {};
// Soll die Route gespeichert werden?
shouldDetach(route: ActivatedRouteSnapshot): boolean {
// Hier kannst du filtern, welche Route gespeichert werden soll (z.B. 'produktbaum')
return route.routeConfig?.path === 'produktbaum';
}
// Speichert die Komponente
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle): void {
this.handlers[route.routeConfig?.path!] = handle;
}
// Soll eine gespeicherte Route wiederhergestellt werden?
shouldAttach(route: ActivatedRouteSnapshot): boolean {
return !!this.handlers[route.routeConfig?.path!];
}
// Holt die gespeicherte Komponente zurück
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle {
return this.handlers[route.routeConfig?.path!];
}
// Soll die Route beim Navigieren wiederverwendet werden?
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
return future.routeConfig === curr.routeConfig;
}
}