user4470482
user4470482

Reputation:

Is there anything like APP_INITIALIZER for lazy loaded modules in Angular?

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.

Upvotes: 3

Views: 3547

Answers (1)

Paul A. Trzyna
Paul A. Trzyna

Reputation: 300

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

Upvotes: 4

Related Questions