I have one page with sections and fixed menu. When user clicks on menu item, the page will scroll to corresponding section.
For scrolling I use https://github.com/Nolanus/ng2-page-scroll
How do I add 'active' class to menu item on click and also when user scrolls to new section?
EDIT:
Progress -- add 'active' class on Click:
My html:
<ul class="nav nav-menu">
<li class="" [class.active]="activeLink == 'item1'" (click)="setActiveLink('item1')">
<a pageScroll href="#item1">item 1</a>
</li>
</ul>
And in my component:
private activeLink: string = 'default-active-link';
setActiveLink(link: string){
this.activeLink = link;
}
But how to get it working also on scroll?