From 7ccdfed018d3c8695ab3637845dba4bec20e5b89 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Thu, 8 Oct 2015 20:42:24 -0500 Subject: [PATCH] feat(nav-controller): remove method --- ionic/components/nav/nav-controller.ts | 20 ++++++++++++++++++++ ionic/components/nav/nav.ts | 4 +--- ionic/components/nav/test/basic/index.ts | 5 +++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 05baab9aa9..91edc2d10e 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -335,6 +335,26 @@ export class NavController extends Ion { return Promise.resolve(); } + /** + * Removes a view from the nav stack at the specified index. + * @param {TODO} index TODO + * @returns {Promise} TODO + */ + remove(index) { + if (index < 0 || index >= this._views.length) { + return Promise.reject("Index out of range"); + } + + let viewToRemove = this._views[index]; + if (this.isActive(viewToRemove)){ + return this.pop(); + } else { + this._remove(index); + viewToRemove.destroy(); + return Promise.resolve(); + } + } + /** * Set the view stack to reflect the given component classes. * @param {TODO} components TODO diff --git a/ionic/components/nav/nav.ts b/ionic/components/nav/nav.ts index 5aa2b388a9..ffc10b4000 100644 --- a/ionic/components/nav/nav.ts +++ b/ionic/components/nav/nav.ts @@ -437,9 +437,7 @@ class Pane { showNavbar(hasNavbar) { this.navbar = hasNavbar; - if (!hasNavbar) { - this.renderer.setElementAttribute(this.elementRef, 'no-navbar', ''); - } + this.renderer.setElementAttribute(this.elementRef, 'no-navbar', hasNavbar ? null : '' ); } } diff --git a/ionic/components/nav/test/basic/index.ts b/ionic/components/nav/test/basic/index.ts index 3f6ead453f..d20838f9bf 100644 --- a/ionic/components/nav/test/basic/index.ts +++ b/ionic/components/nav/test/basic/index.ts @@ -104,6 +104,7 @@ class SecondPage {

+

@@ -124,6 +125,10 @@ class ThirdPage { this.nav.insert(FirstPage, 2); } + removeSecond() { + this.nav.remove(1); + } + }