Is there a way to specifically scroll to an item in a listview using Ionic 2? In my app, I have a listview that is connected to an array.
export class TestPage {
@ViewChild(Content) content: Content;
public items: Array<Object> = [];
ionViewWillEnter() {
console.log(this.navParams.data);
this.customService.getArray(this.params.index).then((items) => {
this.items = items;
//scroll to item
// this.content.scrollTo()
});
}
}
Below is the view:
<ion-list [virtualScroll]="items" approxItemHeight="120px" approxItemWidth="100%"
class="items-listview list list-md">
<button class="items-listview-item item item-md" *virtualItem="let item">
<div class="items-listview-text">
{{ item.text }}<span>{{item.index}}</span>
</div>
</button>
</ion-list>
I noticed that scrollTo only allows scrolling based on position, not the element itself. How can I scroll to a specific listview item (e.g. item number 150)? Is there a way to determine the position of the specific item and pass it to scrollTo?