diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 0dde99b465..c2574cc07c 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -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 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; } diff --git a/ionic/components/tabs/test/basic/index.ts b/ionic/components/tabs/test/basic/index.ts index d1357ef7ca..82628beee0 100644 --- a/ionic/components/tabs/test/basic/index.ts +++ b/ionic/components/tabs/test/basic/index.ts @@ -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 {

Tab 3

+

+ +

` }) -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({