JS:未处理的承诺拒绝:无法匹配任何路线。 URL段:'resetPasswordRequest /:id';

时间:2018-12-21 15:07:05

标签: typescript nativescript auth-guard

我有这个路由器。

  { path: 'resetPasswordRequest/:id', component: ResetPassIdComponent, canActivate: [AuthGuard]}

在组件ResetPassIdComponent中,我使用以下代码获取ID:

ngOnInit(): any {
    let myid = this.route.snapshot.paramMap.get("id")
    this.id = myid;
  }

我现在想要如何创建一个在该组件ResetPassIdComponent中导航的AuthGurad。

我尝试使用此代码,但不起作用

更新:

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let productId = route.params.id;
if (this.auth.isAuthenticated()) {
    return true;
}
this.router.navigate(['/resetPasswordRequest/' + productId]);
return false;

}

在控制台中显示:resetPasswordRequest / 123456789

但不能在此处组件中导航。

0 个答案:

没有答案