mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
test(nav): fix alert test
This commit is contained in:
@ -46,7 +46,7 @@ class MyCmpTest {}
|
|||||||
<button ion-item [navPush]="FirstPage" [navParams]="{id: 23}">Push w/ [navPush] and [navParams]</button>
|
<button ion-item [navPush]="FirstPage" [navParams]="{id: 23}">Push w/ [navPush] and [navParams]</button>
|
||||||
<button ion-item (click)="setPages()">setPages() (Go to PrimaryHeaderPage)</button>
|
<button ion-item (click)="setPages()">setPages() (Go to PrimaryHeaderPage)</button>
|
||||||
<button ion-item (click)="setRoot()">setRoot(PrimaryHeaderPage) (Go to PrimaryHeaderPage)</button>
|
<button ion-item (click)="setRoot()">setRoot(PrimaryHeaderPage) (Go to PrimaryHeaderPage)</button>
|
||||||
<button ion-item (click)="nav.pop()">Pop</button>
|
<button ion-item (click)="navCtrl.pop()">Pop</button>
|
||||||
<button ion-item (click)="viewDismiss()">View Dismiss</button>
|
<button ion-item (click)="viewDismiss()">View Dismiss</button>
|
||||||
<button ion-item (click)="quickPush()">New push during transition</button>
|
<button ion-item (click)="quickPush()">New push during transition</button>
|
||||||
<button ion-item (click)="quickPop()">New pop during transition</button>
|
<button ion-item (click)="quickPop()">New pop during transition</button>
|
||||||
@ -66,8 +66,8 @@ class FirstPage {
|
|||||||
@ViewChild(Content) content: Content;
|
@ViewChild(Content) content: Content;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private nav: NavController,
|
public navCtrl: NavController,
|
||||||
private view: ViewController
|
public view: ViewController
|
||||||
) {
|
) {
|
||||||
for (var i = 1; i <= 50; i++) {
|
for (var i = 1; i <= 50; i++) {
|
||||||
this.pages.push(i);
|
this.pages.push(i);
|
||||||
@ -79,36 +79,36 @@ class FirstPage {
|
|||||||
{ page: PrimaryHeaderPage }
|
{ page: PrimaryHeaderPage }
|
||||||
];
|
];
|
||||||
|
|
||||||
this.nav.setPages(items);
|
this.navCtrl.setPages(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
setRoot() {
|
setRoot() {
|
||||||
this.nav.setRoot(PrimaryHeaderPage);
|
this.navCtrl.setRoot(PrimaryHeaderPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushPrimaryHeaderPage() {
|
pushPrimaryHeaderPage() {
|
||||||
this.nav.push(PrimaryHeaderPage);
|
this.navCtrl.push(PrimaryHeaderPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushFullPage() {
|
pushFullPage() {
|
||||||
this.nav.push(FullPage, { id: 8675309, myData: [1, 2, 3, 4] });
|
this.navCtrl.push(FullPage, { id: 8675309, myData: [1, 2, 3, 4] });
|
||||||
}
|
}
|
||||||
|
|
||||||
pushAnother() {
|
pushAnother() {
|
||||||
this.nav.push(AnotherPage);
|
this.navCtrl.push(AnotherPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
quickPush() {
|
quickPush() {
|
||||||
this.nav.push(AnotherPage);
|
this.navCtrl.push(AnotherPage);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.nav.push(PrimaryHeaderPage);
|
this.navCtrl.push(PrimaryHeaderPage);
|
||||||
}, 150);
|
}, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
quickPop() {
|
quickPop() {
|
||||||
this.nav.push(AnotherPage);
|
this.navCtrl.push(AnotherPage);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.nav.remove(1, 1);
|
this.navCtrl.remove(1, 1);
|
||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ class FirstPage {
|
|||||||
<ion-content padding>
|
<ion-content padding>
|
||||||
<h1>Full page</h1>
|
<h1>Full page</h1>
|
||||||
<p>This page does not have a nav bar!</p>
|
<p>This page does not have a nav bar!</p>
|
||||||
<p><button (click)="nav.pop()">Pop</button></p>
|
<p><button (click)="navCtrl.pop()">Pop</button></p>
|
||||||
<p><button class="e2eFrom2To3" (click)="pushPrimaryHeaderPage()">Push to PrimaryHeaderPage</button></p>
|
<p><button class="e2eFrom2To3" (click)="pushPrimaryHeaderPage()">Push to PrimaryHeaderPage</button></p>
|
||||||
<p><button (click)="pushAnother()">Push to AnotherPage</button></p>
|
<p><button (click)="pushAnother()">Push to AnotherPage</button></p>
|
||||||
<p><button (click)="pushFirstPage()">Push to FirstPage</button></p>
|
<p><button (click)="pushFirstPage()">Push to FirstPage</button></p>
|
||||||
@ -147,10 +147,10 @@ class FirstPage {
|
|||||||
})
|
})
|
||||||
class FullPage {
|
class FullPage {
|
||||||
constructor(
|
constructor(
|
||||||
private nav: NavController,
|
public navCtrl: NavController,
|
||||||
private app: App,
|
public app: App,
|
||||||
private alertCtrl: AlertController,
|
public alertCtrl: AlertController,
|
||||||
private params: NavParams
|
public params: NavParams
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
setPages() {
|
setPages() {
|
||||||
@ -159,19 +159,19 @@ class FullPage {
|
|||||||
{ page: PrimaryHeaderPage }
|
{ page: PrimaryHeaderPage }
|
||||||
];
|
];
|
||||||
|
|
||||||
this.nav.setPages(items);
|
this.navCtrl.setPages(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushPrimaryHeaderPage() {
|
pushPrimaryHeaderPage() {
|
||||||
this.nav.push(PrimaryHeaderPage);
|
this.navCtrl.push(PrimaryHeaderPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushAnother() {
|
pushAnother() {
|
||||||
this.nav.push(AnotherPage);
|
this.navCtrl.push(AnotherPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushFirstPage() {
|
pushFirstPage() {
|
||||||
this.nav.push(FirstPage);
|
this.navCtrl.push(FirstPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
presentAlert() {
|
presentAlert() {
|
||||||
@ -182,11 +182,12 @@ class FullPage {
|
|||||||
text: 'Dismiss',
|
text: 'Dismiss',
|
||||||
role: 'cancel',
|
role: 'cancel',
|
||||||
handler: () => {
|
handler: () => {
|
||||||
// overlays are added and removed from the root navigation
|
// overlays are added and removed from the app root's portal
|
||||||
// ensure you using the root navigation, and pop this alert
|
// in the example below, alert.dismiss() dismisses the alert
|
||||||
// when the alert is done animating out, then pop off the active page
|
// from the app root portal, and once it's done transitioning out,
|
||||||
this.app.getRootNav().pop().then(() => {
|
// this the active page is popped from the nav
|
||||||
this.app.getRootNav().pop();
|
alert.dismiss().then(() => {
|
||||||
|
this.navCtrl.pop();
|
||||||
});
|
});
|
||||||
|
|
||||||
// by default an alert will dismiss itself
|
// by default an alert will dismiss itself
|
||||||
@ -217,11 +218,11 @@ class FullPage {
|
|||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
<ion-content padding fullscreen>
|
<ion-content padding fullscreen>
|
||||||
<p><button class="e2eFrom3To2" (click)="nav.pop()">Pop</button></p>
|
<p><button class="e2eFrom3To2" (click)="navCtrl.pop()">Pop</button></p>
|
||||||
<p><button (click)="pushAnother()">Push to AnotherPage</button></p>
|
<p><button (click)="pushAnother()">Push to AnotherPage</button></p>
|
||||||
<p><button (click)="pushFullPage()">Push to FullPage</button></p>
|
<p><button (click)="pushFullPage()">Push to FullPage</button></p>
|
||||||
<p><button (click)="setRoot()">setRoot(AnotherPage)</button></p>
|
<p><button (click)="setRoot()">setRoot(AnotherPage)</button></p>
|
||||||
<p><button (click)="nav.popToRoot()">Pop to root</button></p>
|
<p><button (click)="navCtrl.popToRoot()">Pop to root</button></p>
|
||||||
<p><button id="insert" (click)="insert()">Insert first page into history before this</button></p>
|
<p><button id="insert" (click)="insert()">Insert first page into history before this</button></p>
|
||||||
<p><button id="remove" (click)="removeSecond()">Remove second page in history</button></p>
|
<p><button id="remove" (click)="removeSecond()">Remove second page in history</button></p>
|
||||||
<div class="yellow"><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f></div>
|
<div class="yellow"><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f></div>
|
||||||
@ -243,9 +244,9 @@ class FullPage {
|
|||||||
})
|
})
|
||||||
class PrimaryHeaderPage {
|
class PrimaryHeaderPage {
|
||||||
constructor(
|
constructor(
|
||||||
private nav: NavController,
|
public navCtrl: NavController,
|
||||||
private alertCtrl: AlertController,
|
public alertCtrl: AlertController,
|
||||||
private viewCtrl: ViewController
|
public viewCtrl: ViewController
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ionViewWillEnter() {
|
ionViewWillEnter() {
|
||||||
@ -253,23 +254,23 @@ class PrimaryHeaderPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pushAnother() {
|
pushAnother() {
|
||||||
this.nav.push(AnotherPage);
|
this.navCtrl.push(AnotherPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushFullPage() {
|
pushFullPage() {
|
||||||
this.nav.push(FullPage, { id: 8675309, myData: [1, 2, 3, 4] });
|
this.navCtrl.push(FullPage, { id: 8675309, myData: [1, 2, 3, 4] });
|
||||||
}
|
}
|
||||||
|
|
||||||
insert() {
|
insert() {
|
||||||
this.nav.insert(2, FirstPage);
|
this.navCtrl.insert(2, FirstPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeSecond() {
|
removeSecond() {
|
||||||
this.nav.remove(1);
|
this.navCtrl.remove(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
setRoot() {
|
setRoot() {
|
||||||
this.nav.setRoot(AnotherPage);
|
this.navCtrl.setRoot(AnotherPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
presentAlert() {
|
presentAlert() {
|
||||||
@ -303,7 +304,7 @@ class PrimaryHeaderPage {
|
|||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
<ion-item>Back button hidden w/ <code>ion-navbar hideBackButton</code></ion-item>
|
<ion-item>Back button hidden w/ <code>ion-navbar hideBackButton</code></ion-item>
|
||||||
<button ion-item (click)="nav.pop()">Pop</button>
|
<button ion-item (click)="navCtrl.pop()">Pop</button>
|
||||||
<button ion-item (click)="pushFullPage()">Push to FullPage</button>
|
<button ion-item (click)="pushFullPage()">Push to FullPage</button>
|
||||||
<button ion-item (click)="pushPrimaryHeaderPage()">Push to PrimaryHeaderPage</button>
|
<button ion-item (click)="pushPrimaryHeaderPage()">Push to PrimaryHeaderPage</button>
|
||||||
<button ion-item (click)="pushFirstPage()">Push to FirstPage</button>
|
<button ion-item (click)="pushFirstPage()">Push to FirstPage</button>
|
||||||
@ -335,26 +336,26 @@ class AnotherPage {
|
|||||||
bbCount = 0;
|
bbCount = 0;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private nav: NavController,
|
public navCtrl: NavController,
|
||||||
private viewCtrl: ViewController
|
public viewCtrl: ViewController
|
||||||
) {
|
) {
|
||||||
console.log('Page, AnotherPage, constructor', this.viewCtrl.id);
|
console.log('Page, AnotherPage, constructor', this.viewCtrl.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushFullPage() {
|
pushFullPage() {
|
||||||
this.nav.push(FullPage);
|
this.navCtrl.push(FullPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushPrimaryHeaderPage() {
|
pushPrimaryHeaderPage() {
|
||||||
this.nav.push(PrimaryHeaderPage);
|
this.navCtrl.push(PrimaryHeaderPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
pushFirstPage() {
|
pushFirstPage() {
|
||||||
this.nav.push(FirstPage);
|
this.navCtrl.push(FirstPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
setRoot() {
|
setRoot() {
|
||||||
this.nav.setRoot(FirstPage);
|
this.navCtrl.setRoot(FirstPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleBackButton() {
|
toggleBackButton() {
|
||||||
|
Reference in New Issue
Block a user