title: Angular2 equivalent of $document.ready()
body: <p>Simple question, I hope.</p>
  
  <p>I want to run a script when the Angular2 equivalent of $document.ready() is fired. What is the best way to achieve this?</p>
  
  <p>I've tried putting the script at the end of <code>index.html</code>, but as I found out, this doesn't work! I take it that it has to go in some kind of component declaration?</p>
  
  <p>Is it possible to run load the script from a <code>.js</code> file?</p>
  
  <p>EDIT - Code:</p>
  
  <p>I've got the following js and css plugins injected into my application (from the <a href="http://themeforest.net/item/foundry-multipurpose-html-variant-page-builder/11562108">Foundry html theme</a>).</p>
  
  <pre><code>    &lt;link href="css/themify-icons.css" rel="stylesheet" type="text/css" media="all" /&gt;
      &lt;link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" /&gt;
      ...
  
  
      &lt;script src="js/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/flexslider.min.js"&gt;&lt;/script&gt;
      ...
      &lt;script src="js/scripts.js"&gt;&lt;/script&gt; //This initiates all the plugins
  </code></pre>
  
  <p>As noted, the scripts.js 'instantiates' the whole thing, and thus is needed to be run after Angular is ready. <a href="https://plnkr.co/edit/fp3I6kJu15aGbxMValu3?p=catalogue">script.js</a></p>
  
  <p><strong>Got it working:</strong></p>
  
  <pre><code>import {Component, AfterViewInit} from 'angular2/core';
  
  @Component({
    selector: 'home',
    templateUrl: './components/home/home.html'
  })
  export class HomeCmp implements AfterViewInit {
  
  
      ngAfterViewInit() {
         //Copy in all the js code from the script.js. Typescript will complain but it works just fine
      }
  </code></pre>