0

Pretty new to AngularJS - try not to laugh. Having trouble understanding how to properly receive a window.postMessage object in an AngularJS app.

There is an iframe embedded in the AngularJS app page originating from a non-AngularJS app which calls window.postMessage on the parent window in an attempt to send a message object to the AngularJS application.

I do receive the postMessage event successfully, but the event.data is not the message I sent as it is in other non-Angular apps - it looks like something the AngularJS framework created.

Why do I get this result? Is there a proper AngularJS way to successfully receive the message object I'm sending from the other window?

window.addEventListener("message", function(e) { //do stuff here }, false);

I want e.data to be the message I sent from the embedded window.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
PeteW
  • 1
  • 1
  • Please show the code used to invoke `window.postMessage` and the event object that gets received. "It looks like something the Angular framework created" is too vague to understand what is happening. – georgeawg Jan 22 '19 at 00:37
  • This should be able to be accomplished by injecting `$window` and placing the event listener on that rather than the vanilla JS window object. Possible duplicate -- [see here](https://stackoverflow.com/questions/24987676/window-postmessage-between-iframe-and-its-parent-with-angular-does-anyone-have) – charliebeckwith Jan 21 '19 at 23:41
  • AAAAARRRRG! Thank you charliebeckwith and georgeawg for your interest in my problem. I managed to solve it myself though. It turns out that I am a moron and forgot I had 'AngularJS Batarang' extension installed and active in Chrome and totally forgot about it. It was modifying message event data to include info to help debugging - Signed Clueless and Embarrassed. – PeteW Jan 31 '19 at 20:30

0 Answers0