Make a service variable global in Angular 2

Viewed 42483

How can I make a variable in a service in Angular 2 as a global variable so that two different components can access and modify it?

public myMap : Map<string, string> = new Map<string, string>();

This is the map in the service and I'm populating it initially using a component. Now after some time in the application, I need to access the same populated map using a different component. How can I do this?

When I access the map using another component, it displays as undefined.

2 Answers
Related