angular-electron icon indicating copy to clipboard operation
angular-electron copied to clipboard

Lazy loading modules not working

Open isurendrasingh opened this issue 8 years ago • 3 comments

When using lazy loaded routes, i'm getting this error Error: Uncaught (in promise): Error: Loading chunk 0 failed.

I have used this and it's working fine except when i'm using the lazy loading like {path: 'records', loadChildren: './components/records/records.module#RecordsModule', canActivate: [AuthGuardService]}

I thought it is because of {useHash: true}, but after removing this the first part was not working.

isurendrasingh avatar Sep 12 '18 11:09 isurendrasingh

Try to use an absolute path instead of relative path. In your case is something like: loadChildren: 'app/components/records/records.module#RecordsModule'.

shalomdotnet avatar Sep 13 '18 07:09 shalomdotnet

@shalomdotnet I've tried this approach also, but getting same error. The only fix is by changing <base href=""> to <base href="./"> But now the problem is that, when i open child window using the approach mentioned i'm getting error Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'index.html'

isurendrasingh avatar Sep 13 '18 08:09 isurendrasingh

Also in some cases this also worked for me

loadChildren: '../components/records/records.module#RecordsModule'

depends on where we call the module from.

sandeepsuvit avatar Mar 07 '19 12:03 sandeepsuvit