How to trigger an angular js watch in a specific browser window, when close another browser window
<p>I need to trigger an angular js <code>watch</code> in a specific browser window, when I close another browser window. I used <code>sessionStorage</code> and <code>localStorage</code> for save the message and then use a watch for them, but didn't worked. Any suggestion?</p>

<p>Example:</p>

<pre><code>//First controller in browser window 1. Listen for the event:

  $scope.$watch(function () {
            return localStorage.composeTransferDatas;
        }, function (newVal, oldVal) {           
            if(newVal != oldVal){
                console.log('Hi');             
            }
        }, true);


//Second controller in browser window 2. Save data in localStorage:

  var arrayWindows = JSON.parse(localStorage.composeTransferDatas);
  arrayWindows['test'] = {data : data, type: type};
  localStorage.composeTransferDatas = JSON.stringify(arrayWindows);
  $window.close();
</code></pre>

<p>Expected that the watch in the first controller was triggered, but it didn't. However the localStorage is actually changed.</p>