title: Angular 6 injecting window token in library service
body: <p>I have a library that has the code from this website post:
  <a href="https://brianflove.com/2018/01/11/angular-window-provider/" rel="nofollow noreferrer">https://brianflove.com/2018/01/11/angular-window-provider/</a></p>
  
  <p>In my library, I also have a service where I want to have access to the window object. However, adding in the following to the constructor is not working:</p>
  
  <pre><code>@Inject(WINDOW) private window: Window
  </code></pre>
  
  <p>When trying to build the library with the cli, the following error occurs:</p>
  
  <blockquote>
    <p>Metadata collected contains an error that will be reported at runtime:
    Could not resolve type Window.</p>
  </blockquote>
  
  <p>I can change it to use the type any rather than Window, or add @dynamic as a comment and it does then build OK. Is there a better way of doing this?</p>
  
  <p>I'm not sure if this is even the right way to do it, as it also relies on the consumer to have set WINDOW_PROVIDERS in its main app module providers array.</p>