解析中调用router.navigate()函数的原因

问题描述 投票:0回答:1

我正在研究类似于以下代码的代码:

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] ...)
    }
  }
}

在resolve()函数内部调用this.router.navigate()的原因可能是什么?我们需要执行类似操作的正确用例是什么?

angular angular2-routing
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.