title: Change scope from window to angular view
body: <p>I have to integrate with a vendor that uses an iframe. The JS listens for events emitted by the iframe. In my Angular component.ts I have:</p>
  
  <pre><code>ngOnInit() {
   let listener = window.addEventListener ? "addEventListener" : "attachEvent";
   let listen = window[listener];
   let messageEvent = listener == "attachEvent" ? "onmessage" : "message";
   listen(messageEvent, function(e) {
    if (e.origin == 'someURL') {
      console.log(e.data)
      this.doStuff(e.data);
    }
  }, false);
  }
  
  doStuff(data){
   //do stuff
  }
  </code></pre>
  
  <p>The issue is that when this.processMessage() is called I get an error: </p>
  
  <pre><code>ERROR TypeError: this.processMessage is not a function
  </code></pre>
  
  <p>I know this is a scope issue since the scope of 'this' is now the window. What is the best way to handle this situation? </p>
  
  <p>Is </p>
  
  <pre><code> let that = this 
  </code></pre>
  
  <p>outside of listen() acceptable with es6? </p>