Angular 2 Intercepting route events and then routing later Angular 2 Intercepting route events and then routing later angular angular

Angular 2 Intercepting route events and then routing later


you may create a CanActivate guard for the parent Route, where you may stop navigation based upon some Global variable, The variable may have the value based upon if the animation has been shown or not.

So what you may do is,

export class AnimationGuard implements CanActivate {  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {    if(HasAnimationRun){      return true;    }    runAnimation(state.url);    return false;  }}runAnimation(url){  // run animation  // set global variable.  // navigate to url}

Read more about CanActivate here.

Hope this helps!!