1

My side menu has scroll, so when I scroll it all the way to the bottom and close it, I need it to reopen with the scroll position at the top.

Currently, I'm trying to access the side menu component from app.component.ts, but calling the scrollToTop method doesn't do anything.

// app.component.html
<ion-menu
  type="overlay"
  side="right"
  [swipeEnabled]="false"
  [content]="content"
  (ionClose)="sideMenuScrollTop()"
>
<sidemenu [nav]="nav"></sidemenu>
</ion-menu>
<ion-nav [root]="rootPage" #content></ion-nav>

// app.component.ts
@ViewChild(SideMenuComponent)
sideMenu: SideMenuComponent;

sideMenuScrollTop() {
  this.sideMenu.content.scrollToTop();
}

// sidemenu.component.ts
@ViewChild(Content)
content: Content;

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.