1

There is a way in Angular to load routed feature modules lazily.
This means if I want to load some module lazily I have to define it in router.

Is there any way to load modules that are not routed lazily?
Meaning without defining them in the routes, without reflecting their path in URL, I just want to load them upon specific event in the application.

1 Answer 1

1

Angular now has the ability to lazy load code and components using dynamic import().

There's a good example of using import().then() to load specific components and then add them to a view: https://johnpapa.net/angular-9-lazy-loading-components/ However, as the article notes, loading a hierarchy of components is not so easy.

There's also a more detailed look at importing a module here: https://indepth.dev/lazy-loading-angular-modules-with-ivy/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.