-1

Situation: I need to write a Routing mechanism in Angular for an Application that has more than 1500 pages.

Requirements: I need an Angular-Routing mechanism which is:

  1. Readable - I shouldn't have to include all my Route-list in my Angular app.
  2. Scalable - New Routes should also work dynamically.
  3. Efficient - the initial bundle size should not be large and the routing process should not be slow.

Question: I want to take the Route referenced in Angular-Routing at runtime (dynamically) and render the Component related to that route by lazy-loading it at runtime. How can I achieve this?

I did try lazy-loading with "loadChildren import", but I couldn't do it dynamically in runtime to control which exact component I want to load according to the requested route

  • Did you consider wild-card routes? How would you decide which route loads which component? – MikeOne Aug 07 '23 at 08:06
  • I want to store components exactly as in my routes. e.g. if the requested route is like: "example/module/staff_list" then the application should try to load the component from that path, if it fails to load it should return a 404 component. – Sardor Bayramov Aug 07 '23 at 11:30
  • Sounds like you want file based routing? That is not natively supported bij Angular. Maybe have a look at AnalogJS? – MikeOne Aug 08 '23 at 16:15
  • I am actually migrating from AngularJS project – Sardor Bayramov Aug 09 '23 at 22:37

0 Answers0