I have an Angular 2 app which I'd like to keep as lean as possible (traffic-wise) and load certain data sets (from API URL) only when it is required.
The service that is responsible for loading the data is passed to a ui component constructor as a dependency. The component template has many references to the service's properties and methods. I can initiate the data loading in the constructor, but since the loading happens asynchronously, the component is already rendered when the data arrives.
So, basically, I am looking for a way to defer the component rendering until the service is initialized with the fresh data loaded from API. Currently I have a basic route with component that checks if the service is initialized, and navigates to the final route when it has finished initialization. But this is not pretty because it requires two routes for one view.