title: Javascript Script inside HTML is not executing with Angular 12
body: <p>Problem: I am trying to hide my navigation bar on scroll-down and show it on scroll-up. I placed my JavaScript to do this inside my <code>HTML</code> body at the bottom of the page, but it does not work. Any help is appreciated.</p>
  <p><strong>HTML(mainpage.component.html):</strong></p>
  <pre><code>&lt;body&gt;
      &lt;div class=&quot;flex&quot; id=&quot;outercontainer&quot;&gt;    
          &lt;nav id=&quot;navbar&quot;&gt;
              &lt;a href=&quot;#&quot; class=&quot;brand&quot;&gt;Brand Name&lt;/a&gt;
              &lt;ul&gt;
                  &lt;li class=&quot;active&quot;&gt;&lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;#about&quot;&gt;About&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;#blogs&quot;&gt;Services&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;#gallery&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/nav&gt;
          &lt;div&gt;
          //content
          &lt;/div&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
      var lastScrollTop = 0;
      navbar = document.getElementById(&quot;navbar&quot;);
      window.addEventListener(&quot;scroll&quot;,function(){
          var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
          if(scrollTop &gt; lastScrollTop){
              navbar.style.top=&quot;-80px&quot;;
          } else{
              navbar.style.top=&quot;0&quot;;
          }
          lastScrollTop = scrollTop;
      })    
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  <p>CSS (mainpage.component.scss)</p>
  <pre><code>*{
      margin:0;
      padding:0;
      box-sizing: border-box;
      font-family: 'Montserrat', sans-serif ;
      scroll-behavior: smooth;
  }
  nav{
      position: fixed;
      top: 0;
      width: 100%;
      height: 80px;
      background:#607d8b;
      padding: 0 100px;
      box-sizing: border-box;
      display: flex;
      justify-content: space-between;
      align-items: center;
      transition: 0.5s;
  }
  ul{
      margin: 0;
      padding: 0;
      display: flex;
  }
  ul li{
      list-style: none;
  }
  ul li a{
      color: #fff;
      padding: 0 20px;
      font-size: 1.1em;
      text-decoration: none;
      font-weight: bold;
  }
  .brand{
      font-size: 1.8em;
      color: #fff;
      font-weight: bold;
      text-decoration: none;
  
  }
  body{
      font-family: Arial, Helvetica, sans-serif;
      background-color: #f6edd9;
      text-align: center;
      margin: 0;
  
      #sidebar{
      width: 10vw;
      height: 100vh;
      flex-direction: column;
      justify-content: flex-end;
      max-width: 80px;
      min-width: 30px;
      }
  
  }
  
  #banner{
      width: 100%;
      align-items: center;
  
      #nameimagecontainer{
      width: 60%;
      }
  
      #selfphotocontainer{
      width: 30%;
      }
  }
  
  #contentcontainer{
      font-size: 30px;
  }
  #getintouchbutton{
      font-style: normal;
  }
  #mainpagecontainer{
      width: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;  
  
      #workcontainer{
          width: 100%;
          height: 100vh;
          background-color: green;
      }
      #servicescontainer{
          width: 100%;
          height: 100vh;
          background-color: red;
      }    
  
      #actioncontainer{
          width: 100%;
          height: 100vh;
          background-color: purple;
      }
      #contactcontainer{
          width: 100%;
          height: 100vh;    
          background-color: orange;
      }
  
  }
  </code></pre>
  <p>So far, my script does nothing. Thank you.</p>