2

My question is as it says in the title:

Is it possible to use a singleton service and share data between two components opened in different tab in angular 5?

I'm using a singleton service, where the provider for the service is injected at app module layer.

However, when I open a component in another tab, the data set in the service is no longer available in the opened component?

Is there anyway I could share data between components opened in different tab in angular 2?

I know this can be achieved via local storage and it's storage event in html5/javascript, I'm looking for something specific in angular 5?

I did go thru the "duplicate" question as marked, and I did mention about local storage and storage event, however, I wanted if there is any "angular" way of doing things.

Thank you.

ZamAm123
  • 21
  • 3
  • 2 tabs means 2 separate windows and 2 app instances regardless of framework used. Could use postMessage API also to communicate between windows – charlietfl Dec 11 '17 at 02:40
  • Possible duplicate of [Communication between tabs or windows](https://stackoverflow.com/questions/28230845/communication-between-tabs-or-windows) – Reactgular Dec 11 '17 at 02:40
  • Reference this question: https://stackoverflow.com/questions/45382775/angular-2-single-service-provider-across-multiple-browser-windows/45382965#45382965 I thought it wasn't possible with Angular but then this poster found the solution. – joshrathke Dec 11 '17 at 03:24
  • @joshrathke, I read it, but it does not say anything about "communicating between two tabs"? can you please elaborate? – ZamAm123 Dec 11 '17 at 03:28
  • Using a browser tool like LocalStorage or cookies sounds like your best bet here, depending on how secure you need to keep the data between tabs. – hugmungus Dec 11 '17 at 03:33
  • I agree. The gist of all of the solutions you will find is that Angular can't do this directly, but can do it through tools that access local storage. – joshrathke Dec 11 '17 at 03:53

0 Answers0