I'm using ngx-perfect-scrollbar
with my Angular 5 project. I want to scroll the div
to top when the route changes.
dashboard.html
<div class="main-panel" [perfectScrollbar] #perfectscroll>
<router-outlet></router-outlet>
</div>
dashboard.ts
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
})
export class DashboardComponent implements OnInit {
@ViewChild('perfectscroll') perfectscroll: PerfectScrollbarDirective;
ngOnInit() {
this.router.events.subscribe((evt) => {
if (!(evt instanceof NavigationEnd)) {
return;
}
this.perfectscroll.scrollToTop()
});
}
}
But I get this error :
TypeError: _this.perfectscroll.scrollToTop is not a function