{ "id": "api/router/BaseRouteReuseStrategy", "title": "BaseRouteReuseStrategy", "contents": "\n\n
\n
\n
\n \n API > @angular/router\n
\n \n
\n \n
\n

BaseRouteReuseStrategylink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

This base route reuse strategy only reuses routes when the matched router configs are\nidentical. This prevents components from being destroyed and recreated\nwhen just the fragment or query parameters change\n(that is, the existing component is reused).

\n\n

See more...

\n
\n \n \n \n
\n\nabstract class BaseRouteReuseStrategy implements RouteReuseStrategy {\n shouldDetach(route: ActivatedRouteSnapshot): boolean\n store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void\n shouldAttach(route: ActivatedRouteSnapshot): boolean\n retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null\n shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean\n}\n\n\n \n \n\n
\n\n\n \n\n \n \n
\n

Descriptionlink

\n

This strategy does not store any routes for later reuse.

\n

Angular uses this strategy by default.

\n

It can be used as a base class for custom route reuse strategies, i.e. you can create your own\nclass that extends the BaseRouteReuseStrategy one.

\n\n \n
\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n
\n

Methodslink

\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n shouldDetach()\n \n link

\n \n
\n
\n

Whether the given route should detach for later reuse.\nAlways returns false for BaseRouteReuseStrategy.

\n\n
\n
\n \n\n shouldDetach(route: ActivatedRouteSnapshot): boolean\n\n \n\n
Parameters
\n \n \n \n \n \n \n \n \n \n
\n \n route\n ActivatedRouteSnapshot\n \n \n
\n\n \n
Returns
\n

boolean

\n\n \n\n\n \n\n \n
\n
\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n store()\n \n link

\n \n
\n
\n

A no-op; the route is never stored since this strategy never detaches routes for later re-use.

\n\n
\n
\n \n\n store(route: ActivatedRouteSnapshot, detachedTree: DetachedRouteHandle): void\n\n \n\n
Parameters
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n route\n ActivatedRouteSnapshot\n \n \n
\n \n detachedTree\n DetachedRouteHandle\n \n \n
\n\n \n
Returns
\n

void

\n\n \n\n\n \n\n \n
\n
\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n shouldAttach()\n \n link

\n \n
\n
\n

Returns false, meaning the route (and its subtree) is never reattached

\n\n
\n
\n \n\n shouldAttach(route: ActivatedRouteSnapshot): boolean\n\n \n\n
Parameters
\n \n \n \n \n \n \n \n \n \n
\n \n route\n ActivatedRouteSnapshot\n \n \n
\n\n \n
Returns
\n

boolean

\n\n \n\n\n \n\n \n
\n
\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n retrieve()\n \n link

\n \n
\n
\n

Returns null because this strategy does not store routes for later re-use.

\n\n
\n
\n \n\n retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle | null\n\n \n\n
Parameters
\n \n \n \n \n \n \n \n \n \n
\n \n route\n ActivatedRouteSnapshot\n \n \n
\n\n \n
Returns
\n

DetachedRouteHandle | null

\n\n \n\n\n \n\n \n
\n
\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n\n \n\n \n \n
\n
\n

\n shouldReuseRoute()\n \n link

\n \n
\n
\n

Determines if a route should be reused.\nThis strategy returns true when the future route config and current route config are\nidentical.

\n\n
\n
\n \n\n shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean\n\n \n\n
Parameters
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n future\n ActivatedRouteSnapshot\n \n \n
\n \n curr\n ActivatedRouteSnapshot\n \n \n
\n\n \n
Returns
\n

boolean

\n\n \n\n\n \n\n \n
\n
\n\n \n
\n\n\n\n \n\n\n
\n
\n\n\n" }