Module Lazy Loading with the Angular Router

53 views Asked by At

Helo programmers I tried apply lesson from youtube about project Facebook by anguler but I face problem when I write code :

{
path: '',
loadChildren: () => import('./components/home/home.module').then(m :{HomeModule:HomeModule} => m.HomeModule)

},

I will send you screenshot for code in vedio

enter image description here

but when try code show me these error

enter image description here

these is vedio link : https://www.youtube.com/watch?v=XQA1bbHQJp0&list=LL&index=11&t=763s

2

There are 2 answers

1
Saad Shamsi On

You can try like this:

const routes: Routes = [
  { 
      path: '', 
      loadChildren: () => import('./components/home/home.module').then(m => m.HomeModule) 
  },
  {
      path: '',
      component: LoginComponent
  }
0
Saad Shamsi On

You can try like this:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';


const routes: Routes = [
      { 
          path: '', 
          loadChildren: () => import('./components/home/home.module').then(m => m.HomeModule) 
      },
      {
          path: '',
          component: LoginComponent
      }