import { RouteReuseStrategy , DefaultUrlSerializer , ActivatedRouteSnapshot , DetachedRouteHandle } from "@angular/router" ; export class CustomReuseStrategy implements RouteReuseStrategy { handlers : { [ key ] : DetachedRouteHandle ; } = { } ; calcKey ( route ) { let next = route ; let url = "" ; while ( next ) { if ( next . url ) { url = next . url . join ( '/' ) ; } next = next . firstChild ; } console . debug ( 'url' , url ) ; return url ; } shouldDetach ( route ) { return true ; } store ( route , handle ) { this . handlers [ this . calcKey ( route ) ] = handle ; } shouldAttach ( route ) { return ! ! route . routeConfig && ! ! this . handlers [ this . calcKey ( route ) ] ; } retrieve ( route ) { if ( ! route . routeConfig ) return null ; return this . handlers [ this . calcKey ( route ) ] ; } shouldReuseRoute ( future , curr ) { return this . calcKey ( curr ) === this . calcKey ( future ) ; } }