|
1 | | -import { Component } from '@angular/core'; |
2 | | -import { Platform } from 'ionic-angular'; |
| 1 | +import { Component, ViewChild } from '@angular/core'; |
| 2 | +import { Nav, Platform } from 'ionic-angular'; |
3 | 3 | import { StatusBar } from '@ionic-native/status-bar'; |
4 | 4 | import { SplashScreen } from '@ionic-native/splash-screen'; |
5 | 5 |
|
6 | | -import { HomePage } from '../pages/home/home'; |
| 6 | +import { Page1 } from '../pages/page1/page1'; |
| 7 | +import { Page2 } from '../pages/page2/page2'; |
7 | 8 |
|
8 | 9 |
|
9 | 10 | @Component({ |
10 | 11 | templateUrl: 'app.html' |
11 | 12 | }) |
12 | 13 | export class MyApp { |
13 | | - rootPage = HomePage; |
| 14 | + @ViewChild(Nav) nav: Nav; |
14 | 15 |
|
15 | | - constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { |
16 | | - platform.ready().then(() => { |
| 16 | + rootPage: any = Page1; |
| 17 | + |
| 18 | + pages: Array<{title: string, component: any}>; |
| 19 | + |
| 20 | + constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) { |
| 21 | + this.initializeApp(); |
| 22 | + |
| 23 | + // used for an example of ngFor and navigation |
| 24 | + this.pages = [ |
| 25 | + { title: 'Page One', component: Page1 }, |
| 26 | + { title: 'Page Two', component: Page2 } |
| 27 | + ]; |
| 28 | + |
| 29 | + } |
| 30 | + |
| 31 | + initializeApp() { |
| 32 | + this.platform.ready().then(() => { |
17 | 33 | // Okay, so the platform is ready and our plugins are available. |
18 | 34 | // Here you can do any higher level native things you might need. |
19 | | - statusBar.styleDefault(); |
20 | | - splashScreen.hide(); |
| 35 | + this.statusBar.styleDefault(); |
| 36 | + this.splashScreen.hide(); |
21 | 37 | }); |
22 | 38 | } |
| 39 | + |
| 40 | + openPage(page) { |
| 41 | + // Reset the content nav to have just this page |
| 42 | + // we wouldn't want the back button to show in this scenario |
| 43 | + this.nav.setRoot(page.component); |
| 44 | + } |
23 | 45 | } |
0 commit comments