Angular Communication between 2 window of same Component

1.1k views Asked by At

I am trying to implement communication between two windows.

I open a component new 2 window by using Window.open().

The problem its same component 2 different instance in 2 windows not able to communicate between that 2 windows.

Can you please help in this?

1

There are 1 answers

0
CaeSea On

You could try BroadsastChannel API: https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API

This is the kind of scenario that it is made for.

It is fairly simple. Taken from the docs:

// Connection to a broadcast channel
var bc = new BroadcastChannel('test_channel');

// Example of sending of a very simple message
bc.postMessage('This is a test message.');

// Example of a simple event handler that only
// logs the event to the console
bc.onmessage = function (ev) { console.log(ev); }

// Disconnect the channel
bc.close()