我有一个名为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 { }
请有人告知这里出了什么问题