我有以下路线:
{
path: 'profile',
component: ProfileComponent,
canActivate: [AuthGuard],
resolve: {
profile : ProfileResolve,
}
}
这是我的解析器代码:
public resolve(route: ActivatedRouteSnapshot,
state: RouterStateSnapshot) : Observable<UserProfile | number> {
const userid = this.auth.getUserId();
return this.ps.getProfile(userid).take(1).map(
profile => profile).catch(errorCode => Observable.of(errorCode));
}
验证成功后,我的AuthGuard会调用 router.navigate(['/profile'])
恢复导航,此时我看到旋转变压器防护已激活 . 但问题是解析器似乎导致导航被取消 . 当我打开路由器跟踪器时,我看到分辨率发生了(我已经验证了已解析的数据是正确的)但是即使数据已解析,导航也会被取消,如屏幕截图所示 . 我究竟做错了什么?