title: How to add class on scroll in Angular
body: <p>Just learning Angular again. Installed AngularCLI and am trying to add a class on scroll from what I had before using jquery. Do I need to use [ngClass] to check a variable with window location? I am trying to use @HostListener right now.</p>
  
  <pre><code>$(function () {
   $(document).scroll(function () {
     $nav.toggleClass('scrolled', $(this).scrollTop() &gt; $nav.height());
   });
  });
  
  $(function() {
   $(document).scroll(function() {
    var x = $(this).scrollTop();
    if (x &gt; 3300) {
      $nav.removeClass('scrolled');
    }
   });
  });
  </code></pre>