mardi 24 juillet 2018

Redirect to Angular 6 Route from other application

I am working on angular 6 .. I want to make the user redirects to specific route from outer link .. but when the user clicks the link he got redirected to "index"

and this is my routes

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

and ComponentGuardService

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

I want to make the user redirect to Requests route

thank you :)




Aucun commentaire:

Enregistrer un commentaire