Sunday 24 February 2019

Angular 7: How to detect the reason of NavigationCancel

Something like that tell me the event NavigationCancel occurs, but I would like to know, whatever did trigger that:

e.g. AppComponent (excerpt):

constructor (
  ....
  private router: Router
)  {
     router.events.subscribe(e => {
       if (e instanceof NavigationCancel) {
         // PLEASE TELL ME, WHO DID CALL ME ? <---
       }
     });
   }

Something (a guard, msal,.. etc.) deletes the route everytime if I refresh the browser, the last visited route is gone. Deep Linking is currently not possible.

A workaround would be: I would have to save the last route in the LocalStorage and force the application to switch to that route. Maybe if I can find the trigger, maybe I'll find another solution.



from Angular 7: How to detect the reason of NavigationCancel

No comments:

Post a Comment