mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
expanded insert-views nav test
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicModule, NavController } from '../../../..';
|
||||
import { IonicApp, IonicModule, NavController, NavParams } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
@ -34,14 +34,45 @@ export class FirstPage {
|
||||
<ion-content padding>
|
||||
<h1>Second page</h1>
|
||||
<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>
|
||||
`
|
||||
})
|
||||
export class SecondPage {
|
||||
_index: number = 0;
|
||||
|
||||
constructor(public navCtrl: NavController) {}
|
||||
|
||||
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: `
|
||||
<ion-header>
|
||||
<ion-navbar>
|
||||
<ion-title>Inserted Paged</ion-title>
|
||||
<ion-title>Inserted Paged {{index}}</ion-title>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
<ion-content padding>
|
||||
@ -58,7 +89,12 @@ export class SecondPage {
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
export class InsertPage {}
|
||||
export class InsertPage {
|
||||
index: any;
|
||||
constructor(params: NavParams) {
|
||||
this.index = params.get('index');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
|
Reference in New Issue
Block a user