gpt4 book ai didi

angular - 在 Angular 8 : : ASSERTION ERROR: NgModule 'MyReportsGridComponent' is not a subtype of 'NgModuleType' 中实现延迟加载时出错

转载 作者:行者123 更新时间:2023-12-03 18:29:31 29 4
gpt4 key购买 nike

我阅读了一些文章似乎无法实现延迟加载我的应用程序。我安装了 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'.

在我的 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 { }

有什么建议么?

最佳答案

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

关于angular - 在 Angular 8 : : ASSERTION ERROR: NgModule 'MyReportsGridComponent' is not a subtype of 'NgModuleType' 中实现延迟加载时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57244444/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com