Answer the question
In order to leave comments, you need to log in
How to pass ViewChild to APP_INITIALIZER?
I have some third-party library that is asynchronously initialized and returns a promise after initialization.
The input receives a container in the HTML element in which to render.
export class MapApi {
constructor(container: HTMLElement, props: MapProps = {}) {}
}
Answer the question
In order to leave comments, you need to log in
At the initialization stage, there are no ViewChilds yet, since the template has not yet been initialized. As you yourself wrote. Therefore, you cannot pass an HTMLElement to an initializer.
The disadvantage of your solution is that the whole application waits for the map to be initialized and does not render anything at all. The best solution would be to create a separate component for the map and inside this component already asynchronously load and initialize the map. And at the time of loading / initializing, show some kind of loader or stub. In this case, you will show the user at least the skeleton of the application, and when ready, the map.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question