title: Angular redirect to previous page after login not working
body: <p>I've tried using the solution below to redirect user to previous page after sign in but it does not redirect right away to the previous url. It goes to "/" route. When I hit F5 to refresh page, it finally goes to the state.url captured before.</p>
  
  <p>Here is my <code>auth.guard.ts</code></p>
  
  <pre><code>canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
      let url: string = state.url;
      if (localStorage.getItem('isLoggedin')) {
          console.log("logged in");
          return true;
      } else {
          console.log('Could not authenticate');
          this.router.navigate(['/login'],{ queryParams : { 'redirectURL' : url }});
          return false;
      }
  }
  </code></pre>
  
  <p>How do I make it go right away to state.url after login?</p>
  
  <p>Edit: I added a <code>console.log(route)</code> right after the <code>console.log("logged in")</code> output and there is no object attached to <code>queryParams</code> attribute. 
  I was expecting to see the <code>redirectURL</code> attached.</p>
  
  <p><a href="https://i.stack.imgur.com/hPp15.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hPp15.png" alt="enter image description here"></a></p>