Angular 子模块的延迟加载不起作用?
Angular lazy load of child module is not working?
我有一个名为 branch 的子模块,我只想在导航到“/branch”时加载它 url 但出现以下错误
ERROR Error: Uncaught (in promise): TypeError: undefined is not a function
TypeError: undefined is not a function
at Array.map (<anonymous>)
at webpackAsyncContext ($_lazy_route_resource lazy namespace object:15)
导航与routerLink一起使用如下
<button mat-raised-button color="accent" [routerLink]="['/branch']">View Branches</button>
app-routing-module.ts 是:
const routes: Routes = [
{ path: 'branch', loadChildren: './branch/branch.module#BranchModule' },
];
分支模块是:
@NgModule({
imports: [
CommonModule,
RouterModule.forChild([{
path: '', component: BranchComponent,
},
{
path: 'view/:id', component: ViewBranchComponent
}
])
],
declarations: [BranchComponent, ViewBranchComponent],
exports: [BranchComponent, ViewBranchComponent, RouterModule]
})
export class BranchModule { }
请有人告诉我这里出了什么问题
似乎您已将 LazyLoad 模块导入 app.module.here,请参阅此处的相关问题 rom Github
。
我有一个名为 branch 的子模块,我只想在导航到“/branch”时加载它 url 但出现以下错误
ERROR Error: Uncaught (in promise): TypeError: undefined is not a function
TypeError: undefined is not a function
at Array.map (<anonymous>)
at webpackAsyncContext ($_lazy_route_resource lazy namespace object:15)
导航与routerLink一起使用如下
<button mat-raised-button color="accent" [routerLink]="['/branch']">View Branches</button>
app-routing-module.ts 是:
const routes: Routes = [
{ path: 'branch', loadChildren: './branch/branch.module#BranchModule' },
];
分支模块是:
@NgModule({
imports: [
CommonModule,
RouterModule.forChild([{
path: '', component: BranchComponent,
},
{
path: 'view/:id', component: ViewBranchComponent
}
])
],
declarations: [BranchComponent, ViewBranchComponent],
exports: [BranchComponent, ViewBranchComponent, RouterModule]
})
export class BranchModule { }
请有人告诉我这里出了什么问题
似乎您已将 LazyLoad 模块导入 app.module.here,请参阅此处的相关问题 rom Github
。