mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
chore(): add callback arg to push
This commit is contained in:
@ -146,7 +146,7 @@ export class NavController extends Ion {
|
|||||||
* @param {TODO} [opts={}] TODO
|
* @param {TODO} [opts={}] TODO
|
||||||
* @returns {Promise} TODO
|
* @returns {Promise} TODO
|
||||||
*/
|
*/
|
||||||
push(componentType, params = {}, opts = {}) {
|
push(componentType, params = {}, opts = {}, callback) {
|
||||||
if (!componentType) {
|
if (!componentType) {
|
||||||
console.debug('invalid componentType to push');
|
console.debug('invalid componentType to push');
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
@ -164,7 +164,10 @@ export class NavController extends Ion {
|
|||||||
this._lastPush = now;
|
this._lastPush = now;
|
||||||
|
|
||||||
let resolve;
|
let resolve;
|
||||||
let promise = new Promise(res => { resolve = res; });
|
let promise = null;
|
||||||
|
if (!callback) {
|
||||||
|
promise = new Promise(res => { callback = res; });
|
||||||
|
}
|
||||||
|
|
||||||
// do not animate if this is the first in the stack
|
// do not animate if this is the first in the stack
|
||||||
if (!this._views.length && !opts.animateFirst) {
|
if (!this._views.length && !opts.animateFirst) {
|
||||||
@ -202,7 +205,7 @@ export class NavController extends Ion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start the transition
|
// start the transition
|
||||||
this._transition(enteringView, leavingView, opts, resolve);
|
this._transition(enteringView, leavingView, opts, callback);
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
@ -579,9 +582,9 @@ export class NavController extends Ion {
|
|||||||
let navbarTemplateRef = viewCtrl.getNavbarTemplateRef();
|
let navbarTemplateRef = viewCtrl.getNavbarTemplateRef();
|
||||||
if (navbarContainerRef && navbarTemplateRef) {
|
if (navbarContainerRef && navbarTemplateRef) {
|
||||||
|
|
||||||
console.time('loadPage ' + viewCtrl.componentType.name + ': createEmbeddedView');
|
console.time('loadPage ' + viewCtrl.componentType.name + ': create navbar');
|
||||||
let navbarView = navbarContainerRef.createEmbeddedView(navbarTemplateRef);
|
let navbarView = navbarContainerRef.createEmbeddedView(navbarTemplateRef);
|
||||||
console.timeEnd('loadPage ' + viewCtrl.componentType.name + ': createEmbeddedView');
|
console.timeEnd('loadPage ' + viewCtrl.componentType.name + ': create navbar');
|
||||||
|
|
||||||
viewCtrl.addDestroy(() => {
|
viewCtrl.addDestroy(() => {
|
||||||
let index = navbarContainerRef.indexOf(navbarView);
|
let index = navbarContainerRef.indexOf(navbarView);
|
||||||
|
@ -114,7 +114,7 @@ export class Tab extends NavController {
|
|||||||
*/
|
*/
|
||||||
load(opts, done) {
|
load(opts, done) {
|
||||||
if (!this._loaded && this.root) {
|
if (!this._loaded && this.root) {
|
||||||
this.push(this.root, null, opts).then(done);
|
this.push(this.root, null, opts, done);
|
||||||
this._loaded = true;
|
this._loaded = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user