Jigneshkumar Zala
Jigneshkumar Zala

Reputation: 51

How to clear routeReuseStrategy manually in Angular 7?

I have a scenario where I need to clear all stored route handlers manually from the component, so that's why I created the following method in custom route reuse strategy and called in component

 deactivateAllHandles(): void {
    this.handlers = {};
  }  

But it's not working? any idea?

Upvotes: 1

Views: 1543

Answers (1)

uminder
uminder

Reputation: 26190

It's hard to provide a reliable answer without seeing the code of your custom route reuse strategy class. It however typically contains a Map that keeps track of individual paths and corresponding detached route handle as shown below.

private routeHandles = new Map<string, DetachedRouteHandle>();

If this is also the case in your custom route reuse strategy class, the clear method could look as follows:

clear() {
   this.routeHandles.clear();
}

Upvotes: 2

Related Questions