How can I share data between 2 components in Angular 2
My use-case is that when I log-in, I enter username and password, based on the username and password I decide on the role of the user and I set that role in a service's setter method.
Now I want to get the role that I have set in this component in my next component. When I try to use the getter method to get the role that it gives me null, which I believe is happening because in my second component, the service instance that I am getting is new instance.
How can I achieve something like this, that I can set some data in some common object and I can retrieve from that object in different components.
Please note that I don't want to pass data from one component to another.