Changing the shouldReuseRoute function to just return false is what might be causing the problem. You can try this.
shouldReuseRoute(
future: ActivatedRouteSnapshot,
curr: ActivatedRouteSnapshot
): boolean {
return curr.routeConfig === null && future.routeConfig === null;
}
As a matter of fact, you re-implement the RouteReuseStrategy class. Had a similar problem and had help from github but unfortunately I can't remember the link.
This is how it will look like.
customReuseRouteStrategy.ts
import {
ActivatedRouteSnapshot,
DetachedRouteHandle,
RouteReuseStrategy
} from "@angular/router";
export class CustomRouteReuseStrategy implements RouteReuseStrategy {
shouldDetach(route: ActivatedRouteSnapshot): boolean {
return false;
}
store(
route: ActivatedRouteSnapshot,
detachedTree: DetachedRouteHandle
): void {}
shouldAttach(route: ActivatedRouteSnapshot): boolean {
return false;
}
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle {
return null;
}
shouldReuseRoute(
future: ActivatedRouteSnapshot,
curr: ActivatedRouteSnapshot
): boolean {
return curr.routeConfig === null && future.routeConfig === null;
}
}
Then in your module providers, you will replace RouteReuseStrategy with the class you just created.
yourmodue.module.ts
providers: [
{
provide: RouteReuseStrategy,
useClass: CustomRouteReuseStrategy
}
]