title: Angular 2 - How to use prerender.io along with lazy loading
body: <p>Since Angular Universal isn't going to be in the CLI for quite a while I must use prerender.io to allow SEO to work properly. However, after some tests it appears that it doesn't work all that great because it doesn't appear to wait for lazy loaded modules so the SEO still fails. </p>
  
  <p>On their site at <a href="https://prerender.io/documentation/test-it" rel="noreferrer">this location</a>, they say this:</p>
  
  <blockquote>
    <p>Is your page only partially rendered?</p>
    
    <p>Our Prerender server tries its best to determine when the page is done
    loading by counting the number of requests in flight. Once the number
    of requests in flight reaches zero, we wait a short period of time and
    then save the HTML. If this is saving the page too early, you can use
    our window.prerenderReady flag to notify the server that your page is
    ready to be saved.</p>
    
    <p>Put this in your HTML:</p>
  
  <pre><code>&lt;script&gt; window.prerenderReady = false; &lt;/script&gt;
  </code></pre>
    
    <p>When we see window.prerenderReady set to false, we'll wait until it's
    set to true to save the HTML. Execute this when your page will be
    ready (usually after ajax calls):</p>
  
  <pre><code>window.prerenderReady = true;
  </code></pre>
  </blockquote>
  
  <p>Here's where I don't understand how to go about it. Since Angular removes script tags from the template (not sure if this is just CLI behavior or Angular itself), I can't set the initial script tag. Nor can I figure out how I would update the <code>window</code> property <code>prerenderReady</code> inside a template script tag from my component class, since I can't just use <code>window.prerenderReady = true</code> and expect it to work since the script has to be added to the template.</p>
  
  <p>Has anyone managed to figure this one out or have any ideas on how I could achieve this?</p>