首页 > 解决方案 > 从其他应用程序重定向到 Angular 6 Route

问题描述

我正在研究 Angular 6 .. 我想让用户从外部链接重定向到特定的路由 .. 但是当用户单击链接时,他被重定向到“索引”

这是我的路线

RouterModule.forRoot([
      { path: "Startup", component: StartupComponent },
      { path: "Login", component: SigninComponent },
      { path: "FirstPage", component: FirstPageComponent },
      { path: "Index", component: IndexComponent, canActivate: [ComponentGuardService] },
      { path: "Requests", component: IndexComponent, canActivate: [ComponentGuardService] },
      { path: "RequestsDetails/:id", component: RequestsDetailsComponent, canActivate: [ComponentGuardService] },
      { path: "RequestsStatistics", component: RequestsStatisticsComponent, canActivate: [AdminGuardService,ComponentGuardService] },

      { path: "", redirectTo: "Index", pathMatch: "full" },
      { path: "**", redirectTo: "Login", pathMatch: "full" }
    ], { useHash: true })

和 ComponentGuardService

canActivate(): boolean {
    let me = Shared.Me;
    if (me == null || me.Id == "") {
      this.navigator.navigate(["/Startup"]);
      return false;
    }
    else
      return true;
  }

我想让用户重定向到请求路由

谢谢你 :)

标签: webangular-ui-routerangular6

解决方案


推荐阅读