子模块的角型延迟加载不起作用?

时间:2018-10-29 01:25:05

标签: angular angular-routing angular7 angular-routerlink

我有一个名为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 { }

请有人告知这里出了什么问题

1 个答案:

答案 0 :(得分:1)

似乎您已将LazyLoad Module导入到您的app.module中。在此处,请在 Github 中查看相关问题。

相关问题