且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果用户已登录,Angular 2重定向

更新时间:2023-12-02 15:18:46

在这种情况下,我可能会将所有内容重定向到 DashboardComponent 使用

In this case I would probably redirect everything to DashboardComponent using

{path:``,redirectTo:'dashboard',pathMatch:'full'}

,然后仪表板组件可以确定用户是否登录(由于AuthGuard处于活动状态),如果用户未登录,它将重定向他以登录

and than the dashboard component can determinate if the user is logged in or not (as it has AuthGuard active), and if the user is not logged in it would redirect him to login.