在角度 8 中实施延迟加载时出错::断言错误:NgModule 'MyReportsGridComponent' 不是 'NgModuleType' 的子类型

elq*_*and 7 lazy-loading angular angular8

我读了一些文章似乎无法实现延迟加载我的应用程序。我安装了 angular 8,似乎我有正确的语法。是否有特定的策略或方法需要组织我的组件以使延迟加载工作?

这是错误消息:

core.js:7187 ERROR Error: Uncaught (in promise): Error: ASSERTION ERROR: NgModule 'MyReportsGridComponent' is not a subtype of 'NgModuleType'.
Error: ASSERTION ERROR: NgModule 'MyReportsGridComponent' is not a subtype of 'NgModuleType'.
Run Code Online (Sandbox Code Playgroud)

在我的 app.routing.module.ts 中,我有什么:

const routes: Routes = [
  {path: '', component:LoginComponent},
  {path: 'Login', component:LoginComponent},
  {path: 'tasks', component:TaskComponent, canActivate:[AuthGuard]},
  {path: 'CreateTask', loadChildren: () => import ('./create-task/create-task.component').then(m => m.CreateTaskComponent), canActivate:[AuthGuard]},
  {path: 'ManageUser', loadChildren: () => import ('./manage-users/manage-users.component').then(m => m.ManageUsersComponent), canActivate:[AuthGuard]},
  {path: 'MyReports', loadChildren: () => import ('./my-reports-grid/my-reports-grid.component').then(m => m.MyReportsGridComponent), canActivate:[AuthGuard]},
  {path: 'CreateTeamName',loadChildren: () => import ('./create-new-team-name/create-new-team-name.component').then(m => m.CreateNewTeamNameComponent), canActivate:[AuthGuard]},
  {path: 'ManageTeams',loadChildren: () => import ('./manage-teams/manage-teams.component').then(m => m.ManageTeamsComponent), canActivate:[AuthGuard]},
  { path: '**', component: PageNotFoundComponent },
  {path: 'Register', component:RegisterComponent}
];

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: true, enableTracing: false, initialNavigation: true, onSameUrlNavigation: 'ignore' })],
  exports: [RouterModule]
})
export class AppRoutingModule { }
Run Code Online (Sandbox Code Playgroud)

有什么建议?

bel*_*uga 8

也偶然发现了这一点。看起来您正在尝试延迟加载组件而不是模块。在这里查看:https : //angular.io/guide/ngmodules