ngx-rocket / generator-ngx-rocket

:rocket: Extensible Angular 14+ enterprise-grade project generator
https://ngx-rocket.github.io/
MIT License
1.53k stars 216 forks source link

Routing Module question #591

Closed buhosiliscodirococo closed 3 years ago

buhosiliscodirococo commented 3 years ago

I'm submitting a...

Minimal reproduction of the problem with instructions

Hi, I'm a newbie to angular. My question is how do the routes work in ngx-rocket?

I explain: Following this example link works all fine, but the module is imported in app.module.ts, compared to the native ngx-rocket about that exists inside app-routing.module.ts

Captura de pantalla 2021-03-10 a la(s) 20 30 29

in other words How could I pass the admin module from the previous example inside app-routing.module.ts (AppRoutingModule)?

and in addition to this very question, If another route that goes through app-routing.module.ts is publicly accessible (example product prices), can it also go through this routing module?

EDIT: I have replicated this block of code, filled the fields (X) and it works perfect . { path: 'XXXXX', loadChildren: () => import('XXXXX').then((m) => m.XXXXXXXX) } Leaving it outside the Shell.childRoutes is for public access .

I spent days trying to figure it out and solve it right now that I created the question ...

Anyway, would that be the correct way to do it or is there another method?

I loved ngx-rocket because it takes you down the path of good practice!

Environment

ngx-rocket 9.2.0 macOS Mojave Visual Studio Code 1.54.1

sinedied commented 3 years ago

By default, the about module is generated as a lazy loaded module (this can be switched off) hence why it's a bit different than the example you linked.

The way you solved it totally fine, you created a new lazy loaded module this way (better perf for your main bundle) 🙂

I encourage you to read the routing basics from the Angular docs, then after that read the lazy loading basics that explains the differences with regular routes.

Good luck with your learning journey!