Angular 在resolve中调用router.navigate()函数的原因

Angular 在resolve中调用router.navigate()函数的原因,angular,angular2-routing,Angular,Angular2 Routing,我正在研究如下代码: export class RouteGuardService implements CanActivate, Resolve<any> { private readonly startPage = 'start' constructor(private router: Router) public async canActivate(...) { ... } public async resolve(...) { if

我正在研究如下代码:

export class RouteGuardService implements CanActivate, Resolve<any> {

  private readonly startPage = 'start'

  constructor(private router: Router)

  public async canActivate(...) {
    ...
  }

  public async resolve(...) {
    if(...) {
      this.router.navigate([route.routeConfig.path ? route.routeConfig.path : this.startPage] ...)
    }
  }
}
导出类RouteGuardService实现CanActivate、Resolve{
专用只读起始页='start'
构造函数(专用路由器:路由器)
公共异步canActivate(…){
...
}
公共异步解析(…){
如果(…){
this.router.navigate([route.routeConfig.path?route.routeConfig.path:this.startPage]…)
}
}
}

在resolve()函数中调用this.router.navigate()的原因可能是什么?我们需要这样做的适当用例是什么?

通常用于在重定向路由之前准备数据。在上述情况下,最佳做法是您可以在实用程序或公共帮助程序服务中定义路由,以便重定向更加顺畅。

可能是因为对于特定数据,您无法显示该组件,而需要显示其他内容?