<ion-toolbar color="primary">
<!-- Segment with anchors -->
<ion-segment [(ngModel)]="view" (ionChange)="segmentChanged($event)">
<ion-segment-button value="0">
<ion-label>Produto</ion-label>
</ion-segment-button>
<ion-segment-button value="1">
<ion-label>Items</ion-label>
</ion-segment-button>
<ion-segment-button value="2">
<ion-label>Insumos</ion-label>
</ion-segment-button>
</ion-segment>
</ion-toolbar>
<!---->
<ion-slides class="ion-no-padding ion-no-margin" (ionSlideDidChange)="slideChanged($event)">
<!-- produto -->
<ion-slide>
<ion-list>
<h1>Produtos</h1>
</ion-list>
</ion-slide>
<!-- items -->
<ion-slide>
<h1>Items</h1>
</ion-slide>
<!-- insumos -->
<ion-slide>
<h1>Insumos</h1>
</ion-slide>
</ion-slides>
@ViewChild(IonSlides, { static: true }) slides: IonSlides;
@ViewChild(IonSegment, { static: true }) segment: IonSegment;
@ViewChild(IonContent, { static: true }) content: IonContent;
public view: any;
ionViewDidEnter() {
this.view = 0;
}
async segmentChanged(event) {
await this.slides.slideTo(this.view);
}
async slideChanged(ev) {
this.view = await this.slides.getActiveIndex();
console.log(this.view);
if (this.view == 1) {
console.log(ev);
this.content.scrollToTop(1500);
}
}