簡體   English   中英

子模塊的角型延遲加載不起作用?

[英]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 { }

請有人能告訴我這里出了什么問題

看來你已經在你的app.module.here importe LazyLoad模塊,請參閱相關的問題ROM Github這里。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM