V
V
Volodya-NRG2017-04-22 13:38:29
Angular
Volodya-NRG, 2017-04-22 13:38:29

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

2 answer(s)
C
Coder321, 2017-04-22
@Volodya-NRG

Create a service, add it to the providers of the main module and inject it to any component

A
Abdulla Mursalov, 2017-04-23
@amaprograma

ngrx/store

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question