1

Having trouble with implementing routing in combination with lazy loading.
My code can be found here: https://github.com/ahartvign/NetCoreDemos

Whenever I try to navigate to my lazy loaded route 'tracking', I get the error:
Cannot find module './trackers/trackers.module'

I've tried multiple different values for loadChildren:

'trackers/trackers.module#TrackersModule'  
'./trackers/trackers.module#TrackersModule'  
'/trackers/trackers.module#TrackersModule' 

And all of the above with default export instead of #TrackersModule.

I've also tried restarting my server, as apparently some people have had problems with that.

  • 1
    I suspect you need to use one of special loaders like `ngtools/webpack`(thanks to the CLI-Team) or `angular-router-loader` (thanks to Brandon Roberts) – yurzui Apr 08 '17 at 16:12
  • @yurzui I installed the angular-router-loader and managed to get it to work. I'm slightly confused as to why I needed to do that though. I thought this functionality was native? I've followed several guides online, and noone has mentioned this. Thanks regardless. – Alexander Hartvig Nielsen Apr 08 '17 at 18:18

1 Answers1

0

Update : Add to your app.routing.ts

export const routing: ModuleWithProviders = RouterModule.forRoot(routes,
        {enableTracing :true , preloadingStrategy :PreloadAllModules }
 );  
Aravind
  • 40,391
  • 16
  • 91
  • 110