mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 13:01:01 +08:00
54 lines
981 B
TypeScript
54 lines
981 B
TypeScript
import {ViewChild} from 'angular2/core';
|
|
import {App, Page, Slides} from 'ionic-angular';
|
|
|
|
|
|
@App({
|
|
templateUrl: 'main.html'
|
|
})
|
|
class MyPage {
|
|
@ViewChild('mySlider') slider: Slides;
|
|
mySlideOptions = {
|
|
initialSlide: 1,
|
|
loop: false
|
|
};
|
|
|
|
ngAfterViewInit() {
|
|
|
|
}
|
|
|
|
onSlideChanged() {
|
|
let previousIndex = this.slider.getPreviousIndex();
|
|
let currentIndex = this.slider.getActiveIndex();
|
|
console.log("Previous index is", previousIndex, "Current index is", currentIndex);
|
|
}
|
|
|
|
goToPrevSlide() {
|
|
this.slider.slidePrev();
|
|
}
|
|
|
|
goToNextSlide() {
|
|
this.slider.slideNext();
|
|
}
|
|
|
|
goToSlide(index) {
|
|
this.slider.slideTo(index);
|
|
}
|
|
|
|
getIndex() {
|
|
let index = this.slider.getActiveIndex();
|
|
console.log("Current Index is", index);
|
|
}
|
|
|
|
getLength() {
|
|
let length = this.slider.length();
|
|
console.log("Current Length is", length);
|
|
}
|
|
}
|
|
|
|
@App({
|
|
template: `<ion-nav [root]="root"></ion-nav>`
|
|
})
|
|
class E2EApp {
|
|
root: Page = MyPage;
|
|
}
|