0

So I have two angularjs applications what i want is to pass a variable from app1 to app2.

So I tried using window popup to pass the variable but its giving me undefined value.

app1

vm.test = test;
function test() {
  var popupWindow = window.open('http://localhost:4000');
  popupWindow.mySharedData = 'testdakjasdhasgdhasdghasgd';
}

app2

$interval(callAtInterval, 1000);

function callAtInterval() {
  // var oldata;
  console.log(window.mySharedData); // giving me undefined value
}
code.cycling
  • 1,246
  • 2
  • 15
  • 33
  • so there is no opportunity to store this data in a database of some sort? and you can not use a shared angular service? – Bryan Dellinger Jan 12 '18 at 02:19
  • @BryanDellinger I also put that into consideration. But when i saw this [SO](https://stackoverflow.com/questions/21519113/angularjs-open-a-new-browser-window-yet-still-retain-scope-and-controller-and) it show that i can pass a variable to another application by using **window.open** – code.cycling Jan 12 '18 at 02:26
  • 1
    You can pass the data as query string parameters. – Intervalia Jan 12 '18 at 04:31

1 Answers1

0

In you first controller do like this inside the test function.

     window.localStorage.setItem(key, value);

Then retrieve that piece of information via this command if it is not a sensitive data.

    window.localStorage.getItem(key)
Ruchira Chamara
  • 345
  • 2
  • 7
  • 20