title: Save redirect URL on auth guard rejection in Angular 4
body: <p>I have a protected route <code>/protected-route</code>. The <code>authentication-guard.service.ts</code> file dictates that a user must be thrown to <code>/login</code> if a valid session is not found:</p>
  
  <pre><code>/* --- Angular --- */
  import { Injectable } from '@angular/core';
  import { CanActivate, Router, RouterStateSnapshot } from '@angular/router';
  
  /* --- Services --- */
  import { AuthenticationService } from './authentication.service';
  import { StorageService } from './storage.service';
  
  @Injectable()
  export class AuthenticatedRouteGuardService implements CanActivate {
  
    constructor(private authenticationService: AuthenticationService, private 
  router: Router, private routerStateSnapshot: RouterStateSnapshot) { }
  
    canActivate() {
  
      if (this.authenticationService.isAuthenticated()) { return true; } else {
  
        console.log(this.routerStateSnapshot.url);
  
        this.router.navigate(['/login']);
  
        return false;
  
      }
  
    }
  
  }
  </code></pre>
  
  <p>I would like to save the attempted route, i.e. <code>/protected-route</code> to be able to redirect the user after successful login. I am unable to get the route information before the user gets thrown to <code>/login</code>. <code>router.url</code> and <code>activatedRoute.snapshot.url</code> both return empty values.</p>