diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index a443ec7194..91edc2d10e 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -253,15 +253,16 @@ export class NavController extends Ion { } /** - * Pop to a specific page in the history stack + * @private + * Pop to a specific view in the history stack * - * @param componentType the page to pop to + * @param view {ViewController} to pop to * @param opts {object} pop options */ - popTo(componentType, opts = {}) { + _popTo(view, opts = {}) { // Get the target index of the view to pop to - let viewIndex = this.getIndexByComponentType(componentType); + let viewIndex = this._views.indexOf(view); let targetIndex = viewIndex + 1; let resolve; let promise = new Promise(res => { resolve = res; }); @@ -271,6 +272,7 @@ export class NavController extends Ion { return; } + opts.direction = opts.direction || 'back'; // get the views to auto remove without having to do a transiton for each @@ -285,7 +287,7 @@ export class NavController extends Ion { } let leavingView = this._views[this._views.length - 1]; - let enteringView = this.getByIndex(viewIndex); + let enteringView = view; if(this.router) { this.router.stateChange('pop', enteringView); @@ -303,7 +305,7 @@ export class NavController extends Ion { * @param opts extra animation options */ popToRoot(opts = {}) { - this.popTo(this._views[0].componentType); + this.popTo(this._views[0]); } /** @@ -814,22 +816,6 @@ export class NavController extends Ion { return null; } - /** - * Get the index of the view with the specified componentType - * @param componentType - * @return index - */ - getIndexByComponentType(componentType) { - if (componentType) { - for (let i = 0, ii = this._views.length; i < ii; i++) { - if (this._views[i].componentType === componentType) { - return i; - } - } - } - return null; - } - /** * TODO * @param {TODO} index TODO diff --git a/ionic/components/nav/test/basic/index.ts b/ionic/components/nav/test/basic/index.ts index 91df16917d..d20838f9bf 100644 --- a/ionic/components/nav/test/basic/index.ts +++ b/ionic/components/nav/test/basic/index.ts @@ -105,7 +105,6 @@ class SecondPage { -

@@ -130,10 +129,6 @@ class ThirdPage { this.nav.remove(1); } - popTo() { - this.nav.popTo(FirstPage); - } - }