3

I am looking for something that lets me execute code when a certain module is initialized. This module is lazy loaded in my application. The APP_INITIALIZER only works for the app initialization process (once at beginning starting at the main module that is bootstrapped).

I cannot use the constructor of the lazy loaded module since my service returns a Promise and I need the response synchronously for working in this lazy loaded module.

1

1 Answer 1

4

Use a resolver. Resolvers are perfect for what you need.

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

3 Comments

This is great to use on component level. Is there something similar to use on module level?
@PhilippEscher One workaround you could use would be to have a module landing view that would use a resolver, it would load all the module level settings and redirect to the requested view.
@PhilippEscher Another idea is to use a module level constructor: bennadel.com/blog/… I have not used this but it looks like a promising workaround.

Your Answer

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