I have been going through articles that covers the same question however most of them are done using javascript. I want to accomplish this in Angular 4 and ironic 3.
Your assistance will be highly appreciated.
I have been going through articles that covers the same question however most of them are done using javascript. I want to accomplish this in Angular 4 and ironic 3.
Your assistance will be highly appreciated.
For Ionic 2 and higher use the scrollToTop()
method on the content class.
page.html
<ion-content>
Add your content here!
</ion-content>
page.ts
import { Component, ViewChild } from '@angular/core';
import { Content } from 'ionic-angular';
@Component({...})
export class MyPage{
@ViewChild(Content) content: Content;
scrollToTop() {
this.content.scrollToTop(400);
}
}
Or you can call scrollTop() whenever you want. Note: 400 is duration in milliseconds, it is optional and you can use this as well
this.content.scrollToTop();
in this case scrollToTop() will set the default value of 300.