0

I am working on an angular application that has 3 modules, root module auth module, and dashboard module. In my root module routing file I load auth and dashboard module using load children approach however dashboard module almost always load first when the user is logged in so I don't want to lazy load my dashboard module.
I search a day and looking for a solution I looked in the angular document to find a way to normal load a module however the only things I found was Angular switch from lazyLoading to 'normal' loading question which the answer doesn't work in aot compile production mode and I got this error

Error: Runtime compiler is not loaded

So how can I normal load my dashboard module in angular?

Daniel.V
  • 2,322
  • 7
  • 28
  • 58
  • https://github.com/angular/angular-cli/issues/14763 – Taras Kovalenko Nov 16 '19 at 07:14
  • @TarasKovalenko I also looked at this Github issue the solution provided in this issue is to use new angular 8 load children syntax which is another way to lazyload module but not normal load https://angular.io/guide/deprecations#loadchildren-string-syntax – Daniel.V Nov 16 '19 at 07:22

1 Answers1

2

If you dont want lazy loading, remove the route corresponding to the load children from the root routing module. Instead place the import statement of the feature module(in your case auth and dashboard module) before the root routing module import. Angular will compile your feature module since it is in the imports array(not lazy load). Since the order matters, the routes in the feature module will be hit first rendering the feature modules' components.

I suggest you to read the documentation for routing and navigation from the official docs

Morsh
  • 171
  • 2
  • 5
  • Also https://stackoverflow.com/a/46627398/12376898 answer's module approach is suitable for your case. – Morsh Nov 16 '19 at 07:24