fix(nav): fire lifecycle events from app root portal

This commit is contained in:
Adam Bradley
2016-08-04 22:47:36 -05:00
parent 8eb0667b79
commit a4e393b619
3 changed files with 30 additions and 3 deletions

View File

@ -137,6 +137,7 @@ class E2EPage {
`
})
class NavigableModal {
constructor(public navCtrl: NavController) {}
submit() {
@ -158,11 +159,11 @@ class NavigableModal {
`
})
class NavigableModal2 {
constructor(public navController: NavController) {
}
constructor(public navCtrl: NavController) {}
submit() {
this.navController.pop();
this.navCtrl.pop();
}
}

View File

@ -193,6 +193,13 @@ export class NavControllerBase extends Ion implements NavController {
// get the leaving view which the _insert() already set
let leavingView = this.getByState(STATE_INIT_LEAVE);
if (!leavingView && this._isPortal) {
// if we didn't find an active view, and this is a portal
let activeNav = this._app.getActiveNav();
if (activeNav) {
leavingView = activeNav.getByState(STATE_INIT_LEAVE);
}
}
// start the transition, fire resolve when done...
this._transition(enteringView, leavingView, opts, done);
@ -224,6 +231,14 @@ export class NavControllerBase extends Ion implements NavController {
// first see if there's an active view
let view = this.getActive();
if (!view && this._isPortal) {
// if we didn't find an active view, and this is a portal
let activeNav = this._app.getActiveNav();
if (activeNav) {
view = activeNav.getActive();
}
}
if (view) {
// there's an active view, set that it's initialized to leave
view.state = STATE_INIT_LEAVE;
@ -343,6 +358,16 @@ export class NavControllerBase extends Ion implements NavController {
// get the view thats ready to enter
let enteringView = this.getByState(STATE_INIT_ENTER);
if (!enteringView && this._isPortal) {
// if we didn't find an active view, and this is a portal
let activeNav = this._app.getActiveNav();
if (activeNav) {
enteringView = activeNav.last();
if (enteringView) {
enteringView.state = STATE_INIT_ENTER;
}
}
}
if (!enteringView && !this._isPortal) {
// oh nos! no entering view to go to!
// if there is no previous view that would enter in this nav stack

View File

@ -26,6 +26,7 @@ export class NavPortal extends NavControllerBase {
) {
super(null, app, config, keyboard, elementRef, zone, renderer, compiler, gestureCtrl);
this._isPortal = true;
this._init = true;
this.setViewport(viewPort);
app.setPortal(this);