I'm experiencing rather weird behavior when trying to log a window object defined by $window.open() in AngularJS within an $interval
self = this
$scope.childWindow = $window.open(authService.buildAuthorizeUrl(), '_blank')
console.log $scope.childWindow
var1 = "I may not work"
self.var2 = 'I should work'
privateData.authInterval = $interval ->
  console.log $scope.childWindow
  console.log var1
  console.log self.var2
,
  1000
Output
Window {document: document, window: Window, frameElement: null, clientInformation: Navigator, onhashchange: null…}
Window {}
I may not work
I should work
Window {}
I may not work
I should work 
As you can see, the first console.log $scope.childWindow is outputting a fully defined window object.  All others, inside the $interval, are outputting only {}.  I've tried not attaching childWindow to the $scope object, and I've tried attaching it to self.  I've also tried following this example too and experienced the same behavior.  Anyone have any idea why this is happening?  Thanks much.
JSFiddle demo: http://jsfiddle.net/U3pVM/15124/
I tried your code in a browser and while setting a debug point inside the $interval function an empty object is getting logged in the console but the watch inspector on the right shows that $scope.childWindow is not empty. So you might just be able to use $scope.childWindow.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With