延迟加载的组件未呈现Angular 4

时间:2017-10-12 11:55:18

标签: angular lazy-loading

我已经实现了带角度4的延迟加载模块,并且能够成功创建chuck然而当我尝试渲染那个延迟加载的模块时,我正在成功查看,因为我可以在网络中看到并且图像如下所示但是组件未呈现最坏的情况是角度没有任何错误。

请帮帮我如果我遗失了什么。

app.routing.ts

const routes: Routes = [
  { path: 'career-info', loadChildren: 'app/components/career-info/career-info.module#CareerInfoModule', data: { pageName: 'career-info', screenName: 'experience level', screenCategory: 'choose template', title: 'Career Info - My Perfect Cover Letter', isRegisteredUser: true } },
  { path: 'how-it-works', component: HowItWorksComponent, data: { pageName: 'how-it-works', screenName: 'how it works', screenCategory: 'choose template', title: 'How It Works - My Perfect Cover Letter' } },
  { path: '**', loadChildren: 'app/components/career-info/career-info.module#CareerInfoModule' } // TODO: give here 404 component
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})

export class AppRoutingModule { }
export const RoutingComponents = [HowItWorksComponent] 

组块 enter image description here

网络 enter image description here

1 个答案:

答案 0 :(得分:0)

使用 RouterModule.forChild(路由)这将有效。