Angular2 get window width onResize : <p>Trying to figure out how to get window width on resizing events in Angular2. Here is my code:</p>

<pre><code>export class SideNav {

    innerWidth: number;

    constructor(private window: Window){

        let getWindow = function(){
          return window.innerWidth;
        };

        window.onresize = function() {
          this.innerWidth = getWindow();
          console.log(getWindow());
        };
} 
</code></pre>

<p>I am importing window provider globally in the bootstrap.ts file using provide to gain access across my app to window. The problem I am having is this does give me a window size, but on resizing the window - it just repeats the same size over and over even if the window changes size.
See image for console.log example:
<a href="https://i.stack.imgur.com/RtVCD.png" rel="noreferrer">Screenshot image</a></p>

<p>My overall goal is to be able to set the window number to a variable onresize so I can have access to it in the template. Any ideas on what I am doing wrong here?</p>

<p>Thanks!</p>
