Search code examples
angularlazy-loadingangular2-routingangular-routing

Angular routing load wrong component


I have this routing file:

{
    path: '',pathMatch:'full', loadChildren: () => import('./component/login/login.module').then(m =>
      m.LoginModule)
  },
  {
    path: 'section2', loadChildren: () => import('./componenti/section2/section2.module').then(m =>
      m.Section2)
  },

When I go on http://localhost:4200/

I see the login component and it works fine, but when I put the correct parameters I do:

this.router.navigate(['/section2']);

But when I do on /section do it shows me the login component Anyone can help me?


Solution

  • We can debug it better if you can provide a stackblitz

    Looking at above code i can see there is a spelling mistake

    ./componenti

    instead of

    /component for section2