import { RouteReuseStrategy , DetachedRouteHandle , ActivatedRouteSnapshot } from '@angular/router' ; export class GilsdavReuseStrategy implements RouteReuseStrategy { constructor ( ) { } shouldDetach ( route ) { return false ; } store ( route , handle ) { } shouldAttach ( route ) { return false ; } retrieve ( route ) { return null ; } shouldReuseRoute ( future , curr ) { return future && curr ? this . getKey ( future ) === this . getKey ( curr ) : false ; } private getKey ( route ) { if ( route . firstChild && route . firstChild . routeConfig && route . firstChild . routeConfig . path && route . firstChild . routeConfig . path . indexOf ( '**' ) !== - 1 ) { return 'WILDCARD' ; } else if ( ! route . data . localizeRouter && ( ! route . parent || ! route . parent . parent ) && ! route . data . skipRouteLocalization ) { return 'LANG' ; } else if ( route . routeConfig . matcher ) { let keyM = `${ this . getKey ( route . parent ) }/${ route . routeConfig . matcher . name }` ; if ( route . data . discriminantPathKey ) { keyM = `${ keyM }-${ route . data . discriminantPathKey }` ; } return keyM ; } else if ( route . data . localizeRouter ) { let key = `${ this . getKey ( route . parent ) }/${ route . data . localizeRouter . path }` ; if ( route . data . discriminantPathKey ) { key = `${ key }-${ route . data . discriminantPathKey }` ; } return key ; } else { let key = route . routeConfig . path ; if ( route . parent ) { key = `${ this . getKey ( route . parent ) }/${ route . routeConfig . path }` ; } if ( route . data . discriminantPathKey ) { key = `${ key }-${ route . data . discriminantPathKey }` ; } return key ; } } }