title: angular4 document and window are undefined
body: <p>I am using dot net core with angular 4 and webpack config.</p>
  <p>When I am trying to get the window or document in a component or service, I am getting this error:</p>
  <blockquote>
  <p>ReferenceError: document is not defined</p>
  <p>ReferenceError: window is not defined</p>
  </blockquote>
  <p>Here are the errors i am getting:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Microsoft.AspNetCore.NodeServices[0]
        ERROR { ReferenceError: window is not defined
            at _window (C:\gitRepose\AngularCore\FM\FMWebApp\FootballWebApp\ClientApp\dist\main-server.js:30801:12)</code></pre>
  </div>
  </div>
  </p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
        An unhandled exception has occurred: window is not defined
        ReferenceError: window is not defined
      at _window (C:\gitRepose\AngularCore\FM\FMWebApp\FootballWebApp\ClientApp\dist\main-server.js:30801:12)</code></pre>
  </div>
  </div>
  </p>
  <p>I am still new to the webpack stuff, anyone know how i can fix this?
  I need the window to handle when a window is resizing.</p>
  <p>EDIT...</p>
  <p>I managed to get this fixed by removing the pre render from the index.cshtml</p>
  <p>i changed it from this:</p>
  <pre><code>&lt;app asp-prerender-module=&quot;ClientApp/dist/main-server&quot;&gt;Loading...&lt;/app&gt;
  </code></pre>
  <p>to this:</p>
  <pre><code>&lt;app&gt;Loading...&lt;/app&gt;
  </code></pre>
  <p>but now obviously pre rendering on server side won't be happening :/ thus it will slow the app boot up time, any ideas how I can fix this without loosing server side pre rendering?</p>