I'm looking for a way to instantiate multiple services in a component with specific order.
For example, let's say I have 3 services namely time, device, and data services which data service is subscribing to 'time_range' and 'device_list' observables of time and device services to update its data. These 3 services are instantiated in MainComponent after login and this component only requires data service's 'data' for its view.
That means data service should be instantiated before time and device services so that it will be able to detect the changes of time and device services when they're instantiated (initialized in constructor).
I have included those services in "providers: []" of "@Component" decorator of MainComponent and I have no idea how to instantiate data service before other services. I tried changing the order of providers' array but there's no difference in result.
Instantiating data service to AppComponent or on bootstrap would work but I don't want it to exist in larger scope.
I'm new to angular 2 and not sure if I understood the concept of service and component right so I would really appreciate to receive feedbacks of this way of service doing all the logic to provide the data and components just fetching the data from the right service and display to its view.
Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire