title: Angular 6 how to set navbar menu active when user scroll to div id
body: <p>How I can get the div id when I scroll to the div. </p>
  
  <p>My angular 6 app is one page app which when user click to the nav bar the page will slide to the div id (I use ngx-scroll-to). </p>
  
  <p>I have done when user click the navbar menu it will slide to the div and set the class active.</p>
  
  <p>My problem is when user manually scroll, how I can set navbar menu active when it reach the div id.</p>
  
  <pre><code>          &lt;li class="nav-item" [ngClass]="activeRoute=='home' ? 'active' : ''"&gt;
                &lt;a class="nav-link " (click)="active('home')" onclick="return false;" href="#" [ngx-scroll-to]="'#home'"&gt;Home&lt;/a&gt;
            &lt;/li&gt;
            &lt;li class="nav-item" [ngClass]="activeRoute=='services' ? 'active' : ''"&gt;
                &lt;a class="nav-link" (click)="active('services')" onclick="return false;" href="#" [ngx-scroll-to]="'#services'"&gt;Services&lt;/a&gt;
            &lt;/li&gt;
  </code></pre>