mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
docs(demos): nav push/pop api demo
This commit is contained in:
2
demos/nav-push-pop/app.html
Normal file
2
demos/nav-push-pop/app.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<ion-nav id="nav" [root]="rootPage" #content></ion-nav>
|
||||
<ion-overlay></ion-overlay>
|
||||
52
demos/nav-push-pop/index.ts
Normal file
52
demos/nav-push-pop/index.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
|
||||
9
demos/nav-push-pop/main.html
Normal file
9
demos/nav-push-pop/main.html
Normal 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>
|
||||
12
demos/nav-push-pop/page-2.html
Normal file
12
demos/nav-push-pop/page-2.html
Normal 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>
|
||||
Reference in New Issue
Block a user