草庐IT

AuthGuardService

全部标签

javascript - Angular 2/4 : How to restrict access to Login Route if user is already logged in?

我有以下路线定义。exportconstRoutes=RouterModule.forChild([{path:'login',component:LoginComponent},{path:'protected',canActivate:[AuthGuardService],component:ProtectedComponent},{path:'home',component:HomeComponent,canActivate:[AuthGuardService],},]);我已成功实现AuthGuardService,如果用户未登录,它会限制对protected路由的访问。我想要