简体   繁体   中英

Lazy Loaded component is not rendering Angular 4

I have implemented lazy loading module with angular 4 and able to create chuck successfully however when I try to render that lazy loaded module I am getting chuck successfully as I can see in my network and images are as below but component is not rendering and worst case is angular doesn't throw any error.

Please help me out If I am missing something.

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] 

Chunk 在此处输入图片说明

Network 在此处输入图片说明

使用RouterModule.forChild(routes)这将起作用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM