docs(demos): nav push/pop api demo

This commit is contained in:
Drew Rygh
2015-12-08 16:13:54 -06:00
parent e522d2e0ff
commit 397b753567
4 changed files with 75 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
<ion-nav id="nav" [root]="rootPage" #content></ion-nav>
<ion-overlay></ion-overlay>

View File

@@ -0,0 +1,52 @@
import {App, Page, IonicApp, Config, Platform} from 'ionic/ionic';
import {NavController, NavParams} from 'ionic/ionic';
var PAGE_NUM = 2;
@App({
templateUrl: 'app.html'
})
class ApiDemoApp {
constructor() {
this.rootPage = InitialPage;
}
}
@Page({
templateUrl: 'main.html'
})
export class InitialPage {
constructor(nav: NavController) {
this.nav = nav;
}
push() {
this.nav.push(Page2);
}
}
@Page({
templateUrl: "page-2.html"
})
export class Page2 {
constructor(
nav: NavController,
) {
this.nav = nav;
this.pageNum = PAGE_NUM;
}
push() {
PAGE_NUM++;
this.nav.push(Page2);
}
pop() {
if (PAGE_NUM > 2) {
PAGE_NUM--;
}
this.nav.pop();
}
}

View File

@@ -0,0 +1,9 @@
<ion-navbar *navbar>
<ion-title>Nav Push/Pop</ion-title>
</ion-navbar>
<ion-content padding>
<ion-row>
<button full block (click)="push()">.push() new page</button>
</ion-row>
<ion-content>

View File

@@ -0,0 +1,12 @@
<ion-navbar *navbar>
<ion-title>Page {{pageNum}}</ion-title>
</ion-navbar>
<ion-content padding>
<ion-row>
<button full block (click)="push()">.push() another page</button>
</ion-row>
<ion-row>
<button secondary full block (click)="pop()">.pop()</button>
</ion-row>
</ion-content>