Share user variable with all components in Angular

-1

I am developing an app with angle 6 and firebase. I have a service for the login "auth.service.ts" which returns the promise to verify the user's login status.

My question is whether I should invoke the service and run all the promise from all the components or any way I can do it once and that the data stored in a variable (say "user") is available in all components.

    
asked by Gustavo Barragán 17.12.2018 в 00:14
source

1 answer

0

The services in angular are singleton, being able to keep in memory any variable for n components.

To use a service as singleton of several will have to be provided from the common module to several.

The documentation on services can be found on Angular's website services

    
answered by 17.12.2018 в 07:40