Angular routing canActivate AuthGuard transmit query params

后端 未结 1 1579
执念已碎
执念已碎 2021-01-04 13:20

The functionality I want to achieve is to be able to have an url like that :

https://myapp.com/?orgId=xxx&username=yyy

That will pre-fill my lo

相关标签:
1条回答
  • 2021-01-04 14:16

    When using router inside a guard, the queryParamsHandling is not handled. You have to set the redirection query params manually by extracting them from the activated route:

    canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
      // ...
      this.router.navigate(['/login'], { queryParams: route.queryParams });
      // ...
    }
    
    0 讨论(0)
提交回复
热议问题