在到达确切的URL之前,分辨率将我路由到第404页



当我使用url'架构/dectionlements/3'请求时,一切正常,getListDepartementis调用。但是它首先将我路由到404,然后将我路由到确切的URL

    navigateToDepartement() {
    this.router.navigate(['/reload']).then(() => {
      this.router.navigate(['/architecture/departements/' + this.idBranche]);
    })
  }

这是解析器:

      export class DepartmentResolveService implements Resolve<any[]>{
     constructor(public brancheService: BrancheService) { }
     resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> {
    return this.brancheService.getListDepartement(route.params['id'])
  }

我的路由代码:

    const routes: Routes = [
     {
    path: '',
    children: [
      {
        path: '',
        component: BranchesComponent,
      },
      {
        path: 'departements/:id',
        component: DepartmentListComponent,
        resolve: { departement: DepartmentResolveService },
      }
    ]
  }
]

我想在到达URL之前防止传递到404。

我真的不明白您为什么要调用'Reload'页面,您应该删除它,这是您应该做的:

navigateToDepartement() {
      this.router.navigate(['/architecture/departements/' + this.idBranche]);
  } 

无需致电重新加载页,我认为它应该有效

最新更新