Answer the question
In order to leave comments, you need to log in
Angular2 how to create a global service?
How to do it: I pull data from the server and plan to store all this data in the same service that pulls the data. At the same time, I want to use this service, with tightened data, in components (in any).
How to access this service from inside the component?
Imagine: there is a route where a list of elements is shown, in another route, the ability to edit one. And how would it be more correct to use the structure, because it would not be correct to constantly pull up data from the server. Once loaded and, if necessary, only sent to the server in case of a change.
Answer the question
In order to leave comments, you need to log in
Create a service, add it to the providers of the main module and inject it to any component
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question