Reputation: 1519
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?
Upvotes: 0
Views: 51
Reputation: 60518
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.
Upvotes: 2