mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
expanded insert-views nav test
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import { Component, NgModule } from '@angular/core';
|
import { Component, NgModule } from '@angular/core';
|
||||||
import { IonicApp, IonicModule, NavController } from '../../../..';
|
import { IonicApp, IonicModule, NavController, NavParams } from '../../../..';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -34,14 +34,45 @@ export class FirstPage {
|
|||||||
<ion-content padding>
|
<ion-content padding>
|
||||||
<h1>Second page</h1>
|
<h1>Second page</h1>
|
||||||
<button ion-button block (click)="insertPage()">Insert Page</button>
|
<button ion-button block (click)="insertPage()">Insert Page</button>
|
||||||
|
<button ion-button block (click)="removePage()">Remove Page</button>
|
||||||
|
<button ion-button block (click)="removeTwoPages()">Remove Two Pages</button>
|
||||||
|
<button ion-button block (click)="testThing()">Test Thing</button>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class SecondPage {
|
export class SecondPage {
|
||||||
|
_index: number = 0;
|
||||||
|
|
||||||
constructor(public navCtrl: NavController) {}
|
constructor(public navCtrl: NavController) {}
|
||||||
|
|
||||||
insertPage() {
|
insertPage() {
|
||||||
this.navCtrl.insert(1, InsertPage);
|
this.navCtrl.insert(1, InsertPage, {
|
||||||
|
index: this._index++
|
||||||
|
}).then(() => {
|
||||||
|
console.log('INSERTED! Stack:\n', this.navCtrl.getViews());
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
removePage() {
|
||||||
|
this.navCtrl.remove(1, 1).then(() => {
|
||||||
|
console.log('REMOVED! Stack:\n', this.navCtrl.getViews())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
removeTwoPages() {
|
||||||
|
this.navCtrl.remove(this.navCtrl.length() - 2, 2).then(() => {
|
||||||
|
console.log('REMOVED TWO! Stack:\n', this.navCtrl.getViews())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
testThing() {
|
||||||
|
console.log('TEST THING');
|
||||||
|
this.navCtrl.push(InsertPage).then(() => {
|
||||||
|
console.log('Pushed', this.navCtrl.getViews());
|
||||||
|
console.log('Removing', this.navCtrl.getActive().index-1);
|
||||||
|
this.navCtrl.remove(this.navCtrl.getActive().index - 1, 1);
|
||||||
|
console.log('REMOVED! Stack:\n', this.navCtrl.getViews());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +81,7 @@ export class SecondPage {
|
|||||||
template: `
|
template: `
|
||||||
<ion-header>
|
<ion-header>
|
||||||
<ion-navbar>
|
<ion-navbar>
|
||||||
<ion-title>Inserted Paged</ion-title>
|
<ion-title>Inserted Paged {{index}}</ion-title>
|
||||||
</ion-navbar>
|
</ion-navbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
<ion-content padding>
|
<ion-content padding>
|
||||||
@ -58,7 +89,12 @@ export class SecondPage {
|
|||||||
</ion-content>
|
</ion-content>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class InsertPage {}
|
export class InsertPage {
|
||||||
|
index: any;
|
||||||
|
constructor(params: NavParams) {
|
||||||
|
this.index = params.get('index');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
Reference in New Issue
Block a user