test(alert): dismiss alert, then run nav.pop()

This commit is contained in:
Adam Bradley
2016-01-29 23:31:51 -06:00
parent 6a96dae283
commit ecb5e4f031
4 changed files with 57 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
import {Component, Type} from 'angular2/core';
import {App, NavController} from 'ionic/ionic';
import {App, NavController, Alert} from 'ionic/ionic';
import {Page, Config, IonicApp} from 'ionic/ionic';
import {NavParams, NavController, ViewController, IONIC_DIRECTIVES} from 'ionic/ionic';
import {NavParams, ViewController, IONIC_DIRECTIVES} from 'ionic/ionic';
@Component({
@@ -127,6 +127,7 @@ class FirstPage {
<p><button (click)="pushFirstPage()">Push to FirstPage</button></p>
<p><button class="e2eFrom2To1" nav-pop>Pop with NavPop (Go back to 1st)</button></p>
<p><button (click)="setPages()">setPages() (Go to PrimaryHeaderPage, FirstPage 1st in history)</button></p>
<p><button (click)="presentAlert()">Present Alert</button></p>
</ion-content>
`
})
@@ -157,6 +158,31 @@ class FullPage {
this.nav.push(FirstPage);
}
presentAlert() {
let alert = Alert.create();
alert.setTitle('Hello Alert');
alert.setMessage('Dismiss this alert, then pop one page');
alert.addButton({
text: 'Dismiss',
role: 'cancel',
handler: () => {
// overlays are added and removed from the root navigation
// ensure you using the root navigation, and pop this alert
// when the alert is done animating out, then pop off the active page
this.nav.rootNav.pop().then(() => {
this.nav.rootNav.pop();
});
// by default an alert will dismiss itself
// however, we don't want to use the default
// but rather fire off our own pop navigation
// return false so it doesn't pop automatically
return false;
}
});
this.nav.present(alert);
}
}