0

Basically there is a module.ts in every created module of the app for example:

ng generate module newModuleName

then the module is created with the newModuleName.module.ts file

In the file, there is @NgModule with a declarations element.

So I want to dynamically modify the declarations array to prevent all components from being loaded in memory at the same time.

How can I do that?

1
  • What exactly do you mean by "being loaded in memory at the same time" Commented Feb 19, 2019 at 20:15

1 Answer 1

2

If your goal is to prevent all of the components from being downloaded at one time on startup, you can use lazy loading.

Regarding memory, when a component is activated by routing to it or showing it as a child component, it is loaded in memory. As soon as the user navigates away from the page showing the component, the component is destroyed.

So you don't have to do anything in the declarations to make this happen.

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.