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
All checks were successful
Angular Build & Deploy / deploy (push) Successful in 46s
This commit is contained in:
31
src/app/route-reuse.strategy.ts
Normal file
31
src/app/route-reuse.strategy.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user