I want to implement a feature for my app: I want to store some modules of the app on the backend and load them dynamically on the user's demand just before the page is loaded. For example, the user wants to use one tool package and does not want to use the second one, so load and connect the first one only. I am quite struggling with the way of implementing this. The example of Lazy Loading in Angular 2 Docs uses the routes to lazy load modules that is quite inconvenient and I do not know how to evolve it to load modules from the database. Other examples involve entry components, but they seem to be deprecated and naturally, not all my modules have components. Could anyone suggest a proper way to be able to manually load and connect modules from the backend?
For more information, I have a service that represents the tool, and this service has a property that holds the class of the component of the tool, like this:
export class CtSelectionTool implements ConnectableTool {
.....
plotterComponent: any = CtSelectionToolComponent;
.....
}
after loading a page I iterates over the loaded services and dynamically creates the components of the tools in the allocated place via factories. The components are declared in the appropriate module. So I wonder whether I can load this module only when the user demands the usage of the corresponding tool.