how to set segment into angular 6 route?

Viewed 416

Issue: I want to set some segment after user login for ex. http://localhost:4200/#/{dynamic name}/{dynamic name}/app/.. My problem is I navigate /app/... in across application. so I need to add all place this two segments before app. but I want to do global so no need to change in each and everywhere. it is possible?

2 Answers

You can change your router and make all other components as a child component something like this:

ts:

{
    path: ':username/:dynamicName/app',
  component: AdminComponent,
  children: [
   //provide all your other routing like
  {path: 'home', loadChildren: HomeComponent},
  // other routing components
  ]
}

You can handle this in the server hosting end where the app gets deployed.

Related