title: Executing a function on page load, ANGULAR 2
body: <p>I have a simple function, checking the width of the window and according to that value it stretches the content. But when I resize the page and reload the site, nothing happens until I resize the window. How do I call a function on page load in angular2?</p>
  
  <p>My whole <code>app.component.ts</code> file:</p>
  
  <pre><code>import { Component } from '@angular/core';
  
  @Component({
    templateUrl: './app.component.html'
  })
  export class appComponent {
  
    private checkScreenWidth() {
      if (window.innerWidth &lt; 1000 &amp;&amp; window.innerWidth &gt; 499) {
        ...
      } else if (window.innerWidth &lt; 500) {
        ...
      } else {
        ...
      }
    }
  }
  </code></pre>