I am new in Angular 4 developement with typescript :
I want to create a reusable static object in app.component.ts
and get its value in all components
How can I do this ?
Asked
Active
Viewed 475 times
0

Nawrez
- 3,314
- 8
- 28
- 42
-
1https://stackoverflow.com/questions/31026886/how-do-i-share-data-between-components-in-angular-2 – Saurabh Agrawal Nov 07 '17 at 08:48
1 Answers
2
To share values or method between components, you need to create a service
, for example, a user.service.ts
that share the currently logged in user and spread his infos in the components where it is injected.
Here's the official documentation about angular services : https://angular.io/tutorial/toh-pt4

Boulboulouboule
- 4,087
- 1
- 13
- 29