1

Is it possible to have a Main application shell that loads say a list of modules the user has access to (I'll call this app switcher) and loads the first App by default. When the user selects App2 or clicks some app icon the Main Shell would unload App1 module and load App2 module and the routes and navigation would change?

I don't want to have multiple angular applications in IIS but be able to lazy load / unload modules or sub apps.

If so please provide an example or some resource that would help me with this design.

2
  • I see how lazy load modules work but not sure the best way to do this, that's what I'm asking, what approach should I take. Commented Jul 20, 2017 at 15:32
  • There's literally a ton of information you have to know about Angular internals to build a system like that. And also routing updates doesn't make it easier. One of the options is to work directly with PlatformRef. Use bootstrapModuleFactory and destroy methods. However, bear in mind that all API related to bootstrapping is experimental and is currently under review Commented Jul 20, 2017 at 16:01

1 Answer 1

2

Yes, this is absolutely possible, you're going to have a main application that persists and loads additional modules as required. I'm not sure you can force the browser to purge modules once you've switched to another one, but you can certainly load modules on demand.

Have a look at this:

Lazy loading: code splitting NgModules with Webpack

"Let’s talk about code splitting in Angular, lazy-loading and a sprinkle of Webpack. Code splitting allows us to essentially break our codebase down into smaller chunks and serve those chunks on demand, which we call “lazy loading”. So, let’s learn how to do it and some of the concepts/terminology behind it."

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

1 Comment

yeah, I think that's what I'm looking for, I understand lazy loading modules but guess I need to play with it more, I really just want the routes and navigation and maybe even the ui to change depending on the selected application. I guess once it's loaded it wouldn't make sense to unload and reload the module. Guess I'll try this route and see what I come up with. Good Example! Thank you very much.

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.