Angular routing error : Type 'Promise is not assignable to type 'Routes | Type<any> | NgModuleFactory<any> | Observable<Routes | Type<any>

Viewed 25

I just updated my angular app from 13 to 14. After updating it to 14, my lazy-loading routing is not working.

I am getting bunch of error like that: enter image description here

My rougint module is look like that:

 const routes: Routes = [
  {
    path: '',
    component: LayoutComponent,
    canActivate: [AuthGuard],
    children: [
      {
        path: '',
        redirectTo: '/dashboard/home',
        pathMatch: 'full',
      },
      {
        path: 'dashboard',
        loadChildren: (): Promise<DashboardModule> =>
          import('../dashboard/dashboard.module').then(m => m.DashboardModule),
      },
    ],
  },
  { path: '**', redirectTo: '/dashboard' },
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { relativeLinkResolution: 'legacy' })],
  exports: [RouterModule],
})
export class LayoutRoutingModule { }

Why I am having this error and what could be the soltution please?

0 Answers
Related