【发布时间】:2019-12-30 12:56:19
【问题描述】:
我有许多应用程序的通用防护:
export class Guard implements CanActivate {
constructor(private authService: AuthService, private router: Router, private route: ActivatedRoute) {}
async canActivate(route: ActivatedRouteSnapshot) {
const user = await this.authService.getUserAuthenticated();
const hasPerm = user && user.hasPermission(route.data.app);
if (!hasPerm) {
this.router.navigate(['/login/' + this.route.snapshot.params.site, {}]);
}
return true;
}
}
但this.route.snapshot.params.site 的路由为空:"/signin/macro/561"。
路线声明:
{ path: 'signin/:site/:token', loadChildren: 'src/app/auth/auth.module#AuthModule' },
【问题讨论】:
-
你在路线上没有设置任何守卫
标签: angular angular-routing angular-guards