Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic V4 (angular) content.scrollToTop

In Ionic V3.X, this would scroll view to top:

@ViewChild(Content) content: Content;

this.content.scrollToTop();

In Ionic V4, this no longer works - 'Property scrollToTop does not exist on type Content'.

Is there an alternative? Thanks.

like image 419
Larry King Avatar asked Aug 30 '18 04:08

Larry King


2 Answers

Use

@ViewChild(IonContent) content: IonContent;

...

this.content.scrollToTop(500);

It works for me, hope it will help you too. For more details https://www.freakyjolly.com/ionic-4-how-to-scroll-to-top-bottom-using-ion-content-scroll-events/

like image 118
Gleb Avatar answered Sep 30 '22 14:09

Gleb


Seems like the scrollToTop() method was added in v4.0.0-beta.3 but some issues were fixed a few hours ago in v4.0.0-beta.6, so please update Ionic to the beta.6 version and the scrollToTop() method should be available there.

EDIT:

Thanks, but I'm already on V4.0.0-beta.6. Checking API, clearly there is no scrollToTop() anymore.

I'm sorry to insist, but I've just installed V4.0.0-beta.6 and I'm able to use the scrollToTop() method without any problems:

enter image description here

enter image description here

like image 39
sebaferreras Avatar answered Sep 30 '22 13:09

sebaferreras