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