fix(overlay): log error when rootNav is Tabs

Closes #897
This commit is contained in:
Adam Bradley
2016-01-09 23:13:12 -06:00
parent f50336b85f
commit 4bc6d8a6af
2 changed files with 29 additions and 7 deletions

View File

@ -316,9 +316,16 @@ export class NavController extends Ion {
* @returns {Promise} Returns a promise, which resolves when the transition has completed
*/
present(enteringView, opts={}) {
let rootNav = this.rootNav;
let nav = this.rootNav;
enteringView.setNav(rootNav);
if (nav._tabs) {
// TODO: must have until this goes in
// https://github.com/angular/angular/issues/5481
console.error('A parent <ion-nav> is required for ActionSheet/Alert/Modal');
return;
}
enteringView.setNav(nav);
let resolve;
let promise = new Promise(res => { resolve = res; });
@ -339,7 +346,7 @@ export class NavController extends Ion {
});
// the active view is going to be the leaving one (if one exists)
let leavingView = rootNav.getActive() || new ViewController();
let leavingView = nav.getActive() || new ViewController();
leavingView.shouldCache = (isBoolean(opts.cacheLeavingView) ? opts.cacheLeavingView : true);
leavingView.shouldDestroy = !leavingView.shouldCache;
if (leavingView.shouldDestroy) {
@ -347,10 +354,10 @@ export class NavController extends Ion {
}
// add the view to the stack
rootNav._add(enteringView);
nav._add(enteringView);
// start the transition
rootNav._transition(enteringView, leavingView, opts, resolve);
nav._transition(enteringView, leavingView, opts, resolve);
return promise;
}

View File

@ -1,4 +1,4 @@
import {App, Page, NavController} from 'ionic/ionic';
import {App, Page, NavController, Alert} from 'ionic/ionic';
//
// Tab 1
@ -78,10 +78,25 @@ class Tab2 {
</ion-navbar>
<ion-content padding>
<h2>Tab 3</h2>
<p>
<button (click)="presentAlert()">Present Alert</button>
</p>
</ion-content>
`
})
class Tab3 {}
class Tab3 {
constructor(nav: NavController) {
this.nav = nav;
}
presentAlert() {
let alert = Alert.create({
title: 'Alert Title!',
buttons: ['Dismiss']
});
this.nav.present(alert);
}
}
@App({