Home > Software engineering >  Specify url to module for lazy loading in Angular
Specify url to module for lazy loading in Angular

Time:09-09

I'm using lazy loading modules in Angular like this

const routes: Routes = [
  {
    path: 'items',
    loadChildren: () => import('./items/items.module').then(m => m.ItemsModule)
  }
];

The problem is that when serving my application Angular tries to find submodule file by URL /items-items-module.js, while in my project Angular is served from folder /scripts/angular, so built module is located by URL /scripts/angular/items-items-module.js. As a result I'm getting 404 error.

Is there any way to specify path to submodule in this case?

CodePudding user response:

[https://angular.io/guide/lazy-loading-ngmodules][1]

this answer available in this angular website

CodePudding user response:

Did you try adding a base href for the angular project

  • Related