Before our Angular application we first have to load some user profile data before the application can be used. First we used some observable magic to do this in our AppModule but there is a much better way; hook into the Angular initialization process using the APP_INITIALIZER token.
Here is a simplified example on how to use it:
Some things to notice:
- You can specify multiple APP_INITIALIZER injection tokens.
- The factory function should return a function that returns a promise
More information: https://hackernoon.com/hook-into-angular-initialization-process-add41a6b7e