I tried to use custom reuse strategy in my angular2 project, but I found it doesn\'t work with lazy module loading. Anyone who know about this? My project i
RouteReuseStrategy
does work with LazyLoaded components.
The problem here is that you're using route.routeConfig.path
as the key to store and retrieve the Handles.
I don't know why, but with LazyLoaded modules, route.routeConfig.path
is empty when executing shouldAttach
The solution I use is to define a custom key in my routes, like:
{ path: '...', loadChildren: '...module#...Module', data: { key: 'custom_key' } }
This key value can be easily accessed in the ActivatedRouteSnapshot
, like:
route.data.key
With this key you can store and retrieve the handles correctly.