我定义了一条路由,该路由具有一个称为uuid的查询参数
{path: 'is-protected/:uuid', component: protectedComponent, canActivate: [RouteGuardService]}
在路由防护中,我需要检查url是否匹配并且路由参数(:uuid)是否为空。如果路线没有参数,我需要将其重定向到本地路线。我正在尝试使用
if (state.url == 'is-protected'){
if( query param exists){
return true;
}
else {
this.route.navigate(['/']);
}
}
这不会起作用,因为state.url不包含查询参数,因此它将永远不会到达此代码块。
有没有办法检查包含参数的路线是否存在并进行相应导航?
慕婉清6462132
慕慕森
相关分类