1

I have an issue with angular routing. It is a legacy Angular 6 application. My routes are defined such as

Routes = [
 { path: '', component: DashboardComponent,pathMatch: 'full', canActivate: [AuthGuardService]},
 { path: 'seller', component: SellerComponent},
 { path: 'logout',component: LogoutComponent}
]

in app.module I'm using RouterModule.forRoot(appRoutes, {useHash: true}) in app.component.html I have <router-outlet> and link which should take me to logout (loaded in router outlet). <a [routerLink]="['/logout']">Logout</a> The behavior I'm observing is - the url in browser window is changed to ...hostname/logout however the component is not getting loaded in router outlet. In the code I do not see anything obvious that could restrict any redirects. Also, I'm not observing any errors in console. The url changes and nothing happens after that. Has anyone experienced similar issue? At this point I'm clueless what to look for - any filters, interceptors or anything else. Please, suggest what can be the cause of it.

Yakiv
  • 623
  • 2
  • 8
  • 19

2 Answers2

1

The general issue for this type of things are spelling issue or wrong module import or same name of component So, First check for all the spellings of component names and imports if they are correct or not? then check in app.routing.ts if the defined url is match with what you wanna do or call, also check in your logout module for you are calling the right component or not then try after removing path match, and define your router link like so .. routerLink="/logout".

Purvang Gor
  • 108
  • 2
  • 11
0

The cause of this behavior was that router-outlet was wrapped in ng-template and was conditioned to application logic.

Yakiv
  • 623
  • 2
  • 8
  • 19