mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
@ -316,9 +316,16 @@ export class NavController extends Ion {
|
|||||||
* @returns {Promise} Returns a promise, which resolves when the transition has completed
|
* @returns {Promise} Returns a promise, which resolves when the transition has completed
|
||||||
*/
|
*/
|
||||||
present(enteringView, opts={}) {
|
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 resolve;
|
||||||
let promise = new Promise(res => { resolve = res; });
|
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)
|
// 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.shouldCache = (isBoolean(opts.cacheLeavingView) ? opts.cacheLeavingView : true);
|
||||||
leavingView.shouldDestroy = !leavingView.shouldCache;
|
leavingView.shouldDestroy = !leavingView.shouldCache;
|
||||||
if (leavingView.shouldDestroy) {
|
if (leavingView.shouldDestroy) {
|
||||||
@ -347,10 +354,10 @@ export class NavController extends Ion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add the view to the stack
|
// add the view to the stack
|
||||||
rootNav._add(enteringView);
|
nav._add(enteringView);
|
||||||
|
|
||||||
// start the transition
|
// start the transition
|
||||||
rootNav._transition(enteringView, leavingView, opts, resolve);
|
nav._transition(enteringView, leavingView, opts, resolve);
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {App, Page, NavController} from 'ionic/ionic';
|
import {App, Page, NavController, Alert} from 'ionic/ionic';
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tab 1
|
// Tab 1
|
||||||
@ -78,10 +78,25 @@ class Tab2 {
|
|||||||
</ion-navbar>
|
</ion-navbar>
|
||||||
<ion-content padding>
|
<ion-content padding>
|
||||||
<h2>Tab 3</h2>
|
<h2>Tab 3</h2>
|
||||||
|
<p>
|
||||||
|
<button (click)="presentAlert()">Present Alert</button>
|
||||||
|
</p>
|
||||||
</ion-content>
|
</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({
|
@App({
|
||||||
|
Reference in New Issue
Block a user