Using Angular2 to create a single page app, I\'m intercepting unauthenticated user access to non-public routes in a custom RouterOutlet and redirecting them to
Use RouterStateSnapshot in the auth guard to capture the requested URL.
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot)
{
// keep the attempted URL for redirecting
this._loginService.redirectUrl = state.url;
}
Redirect to that URL on successful authentication with using Router (e.g. in the login.component.ts). E.g. this._router.navigateByUrl(redirectUrl);
P.S. Suggestions of @MichaelOryl and @Vitali would work, but my way is more aligned with Angular2 final release.