Search code examples
angularangular-router

Angular stop Router NavigationStart


Is it possible to stop the NavigationStart in Angular? I'm trying to prompt a custom confirmation modal if the user tries to change the route.

constructor(private router: Router) {
    if(val instanceof NavigationStart){
        //prompt the confirmation modal and stop NavigationStart or at least 
          make it wait until user performs any action
    }
}

Solution

  • You can prevent a route was resolving with the CanActivate or CanDeactive class