I work with angular 4 (angular -router@4.4.6 ); I have an instagram-like grid and timeline, I want to remember scrolling after returning from a message, etc ... I use customRouteReuseStrategy shown below but it gives unpredictable behavior
Anyone please give me a solution or an alternative? Thanks
private handlers: { [key: string]: DetachedRouteHandle } = {};
constructor() {
}
shouldDetach(route: ActivatedRouteSnapshot): boolean {
return true;
}
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle): void {
this.handlers[route.url.join("/") || route.parent.url.join("/")] = handle;
}
shouldAttach(route: ActivatedRouteSnapshot): boolean {
return !!this.handlers[route.url.join("/")];
}
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle {
return this.handlers[route.url.join("/") || route.parent.url.join("/")];
}
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
return future.routeConfig === curr.routeConfig;
}
source
share