How to call update() method of in Angular 2 Perfect Scrollbar wrapper?

送分小仙女□ 提交于 2019-12-04 20:18:51

One can do it like this. First, insert perfect-scrollbar selector and give it a custom ID inside an HTML template:

<perfect-scrollbar #scroll1 class="container">
   <div class="dynamic-content"></div>
</perfect-scrollbar>

Then in the typescript file refer to this element using defined ID and assign its type:

@ViewChild('scroll1') scroll1: PerfectScrollbarComponent;

Finally, call update() method through directiveRef property of the Perfect Scrollbar component inside whatever method in the same file:

yourMethod() {
   this.scroll1.directiveRef.update();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!