Trying out Ionic 2
and facing an issue. Created a default side-menu app from CLI with a slider
. Need to start the actual side-menu app from the last slide on button click or anchor link.
My app.ts:
@Component({
templateUrl: 'build/app.html'
})
class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = Slider;
pages: Array<{title: string, component: any}>
constructor(private platform: Platform) {
this.initializeApp();
// for ngFor and navigation example
this.pages = [
{ title: 'Start', component: StartPage },
{ title: 'Farms', component: FarmList }
];
}
initializeApp() {
this.platform.ready().then(() => {
StatusBar.styleDefault();
});
}
openPage(page) {
this.nav.setRoot(page.component);
}
}
ionicBootstrap(MyApp);
My slider.ts:
@Component({
templateUrl: 'build/pages/slider/slider.html'
})
export class Slider {
mySlideOptions = {
initialSlide: 0,
loop: true,
pager: true
};
@ViewChild('mySlider') slider: Slides;
goToSlide() {
this.slider.slideTo(2, 500);
}
}
My slider.html:
<ion-slides #mySlider [options]="mySlideOptions">
<ion-slide>
<h1>Slide 1</h1>
</ion-slide>
<ion-slide>
<h1>Slide 2</h1>
</ion-slide>
<ion-slide>
<h1>Slide 3</h1>
<button>Start</button>
</ion-slide>
</ion-slides>
The default app as created from CLI seems to not be using routing with Angular2
. Does Ionic2
handle routing in its own way?
How can I start my actual app (e.g. 'start' page) from the slider?
https://i.stack.imgur.com/i6H2M.png https://i.stack.imgur.com/9eOt4.png