title: Angular 2 - Run Component Method from Component's Constructor?
body: <pre><code>  constructor() {
  
      document.addEventListener('someEvent', function(event) {
        console.log(event.data);
        this.test(); //throws error - this.test() is undefined
      });
    }
  </code></pre>
  
  <p>If I move it to <code>ngOnInit</code>, it works fine:</p>
  
  <pre><code>  ngOnInit() {
      this.test(); //works ok
    }
  </code></pre>
  
  <p>The function is just a method on the component, defined after the constructor:</p>
  
  <pre><code>  public test(){
      console.log('TEST');
    }
  </code></pre>
  
  <p>My end goal is to run the <code>test()</code> method of my component every time <code>someEvent</code> event fires on the global window (the event comes from raw javascript, i.e. <code>document.dispatchEvent(event, {'detail': evntPayload});</code></p>
  
  <p>How do I accomplish this? </p>