0

Actually it was working before, but today it stopped working and I didn't change anything. That's confused me. Does anyone have any idea about this?

This is my AppRoutingModule

const routes: Routes = [
{
    path: '',
    redirectTo: 'admin', pathMatch: 'full'
},

{
    path: 'admin',
    component: MainComponent,
    canActivate: [AuthService],
    children: [
        {path: '', redirectTo: 'dashboard', pathMatch: 'full'},
        {path: 'dashboard', component: DashboardComponent, data: {breadcrumbs: ['Dashboard']}},
    ]
},

{path: 'auth', loadChildren: () => import('./auth/auth.module').then(a => a.AuthModule)},
{path: '**', component: Error404Component},
]
@NgModule({
imports: [LayoutModule, RouterModule.forRoot(routes, {useHash: true})],
exports: [RouterModule]
})
export class AppRoutingModule {
}

This is my AppModule

@NgModule({
declarations: [
    AppComponent,
    DashboardComponent,
    P404Component
],
imports: [
    BrowserModule,
    AppRoutingModule,
],
exports: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
Ismail Wakra
  • 71
  • 2
  • 7
  • What is 'AppRoutingModule'? You can use RouterModule.forRoot(routes). – Hypenate Jan 21 '22 at 11:45
  • It should work as far as I can see. No errors in the console? Maybe check out https://stackoverflow.com/a/45669041/5695833 – Hypenate Jan 21 '22 at 15:32
  • Yeah, Actually it was working while for a long time, It just surprised me this days by stop working, Everything is right and no error on the console that's confusing – Ismail Wakra Jan 21 '22 at 15:51
  • I found that some people get the same issue with Angular 10.1.0, but I tried the solution that they used to fix it and it's not working too. you can see [link](https://github.com/angular/angular/issues/38691) – Ismail Wakra Jan 21 '22 at 15:55
  • Can you remove canActivate: [AuthService]? Because you redirect on startup, but maybe it's blocking? – Hypenate Jan 21 '22 at 20:34
  • I tried without canActivate, but still the same issue – Ismail Wakra Jan 24 '22 at 08:24
  • On the code you provide it seems fine... maybe add the enabletracing option (see my post above) – Hypenate Jan 24 '22 at 08:29

0 Answers0