documentation is not being very helpful here. I want to use the perfect scroll-bar in my application so that I bypass issues of compatibility with all browsers. I initialized my code exactly as described here https://github.com/zefoy/ngx-perfect-scrollbar/tree/4.x.x/ . This is what I did in my html
<perfect-scrollbar id="chat" [config]="config">
<li *ngFor="let message of messages">
{{messages}}
<li>
</perfect-scrollbar>
now for each new message I want the container to autoscroll to the latest message. Reading further the documentation I found that there'are directives to call events. that is described at the end of the document I linked earlier. So my approach has been the following in the same component:
import {PerfectScrollbarComponent } from 'ngx-perfect-scrollbar';
...
constructor(private scrollbar:PerfectScrollbarComponent) { }
...
ngDoCheck() {
var chat = document.getElementById('chat');
this.scrollbar.directiveRef.scrollToBottom(chat.scrollHeight);
}
This gives me an error because it's expecting PerfectScrollbarComponent to be a provider. After I do that, I get another error No provider for ElementRef!.
I am loosing my sleep over this. Can anyone suggest a suggestion on how to implement autoscrolling with perfectscrollbar in angular 4? Thank you in advance