This base route reuse strategy only reuses routes when the matched router configs are identical. This prevents components from being destroyed and recreated when just the route parameters, query parameters or fragment change (that is, the existing component is reused).
API
abstract class BaseRouteReuseStrategy implements RouteReuseStrategy {
shouldDetach(route: ActivatedRouteSnapshot): boolean;
store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void;
shouldAttach(route: ActivatedRouteSnapshot): boolean;
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null;
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean;
shouldDestroyInjector(route: Route): boolean;
}
shouldDetach
booleanWhether the given route should detach for later reuse. Always returns false for BaseRouteReuseStrategy.
boolean
store
voidA no-op; the route is never stored since this strategy never detaches routes for later re-use.
void
shouldAttach
booleanReturns false, meaning the route (and its subtree) is never reattached
boolean
retrieve
DetachedRouteHandle | nullReturns null because this strategy does not store routes for later re-use.
DetachedRouteHandle | null
shouldReuseRoute
booleanDetermines if a route should be reused. This strategy returns true when the future route config and current route config are identical.
boolean
shouldDestroyInjector
booleanDetermines if the injector for the given route should be destroyed.
This method is called by the router when the RouteReuseStrategy is destroyed. If this method returns true, the router will destroy the injector for the given route.
boolean
Description
This base route reuse strategy only reuses routes when the matched router configs are identical. This prevents components from being destroyed and recreated when just the route parameters, query parameters or fragment change (that is, the existing component is reused).
This strategy does not store any routes for later reuse.
Angular uses this strategy by default.
It can be used as a base class for custom route reuse strategies, i.e. you can create your own class that extends the BaseRouteReuseStrategy one.