Angular2:重定向到一个页面在应用程序启动 [英] Angular2 : Redirect to a page at application startup

查看:524
本文介绍了Angular2:重定向到一个页面在应用程序启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临一个小问题,在我的Angular2 Web应用程序。

I'm facing a little issue for my web application in Angular2..

每个应用程序的启动,我想如果用户具有访问权进行检查。
不过,我不知道如何将用户重定向到的路径,这使得这个过程无论地方他在哪里。

Each application launch, I would check if the user has a right of access. However I don't know how to redirect the user to the route which makes this process whatever the place where he is.

任何想法?

在此先感谢!

推荐答案

有两种常用的方法。

在您检查,如果用户进行身份验证,否则重定向到登录路线

where you check if the user is authenticated otherwise redirect to the login route

另请参阅结果
- <一个href=\"http://stackoverflow.com/questions/36420033/check-if-the-user-logged-in-on-any-page-change-in-angular-2/36420189#36420189\">Check如果用户登录在角2 结果页面的任何改变
- HTTP://www.captain$c$cman .COM / 2016/03/31 / angular2路由安全/

See also
- Check if the user logged in on any page change in Angular 2
- http://www.captaincodeman.com/2016/03/31/angular2-route-security/

这篇关于Angular2:重定向到一个页面在应用程序启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆