feat(nav-controller): remove method

This commit is contained in:
Tim Lancina
2015-10-08 20:42:24 -05:00
parent f199e65767
commit 7ccdfed018
3 changed files with 26 additions and 3 deletions

View File

@ -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

View File

@ -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 : '' );
}
}

View File

@ -104,6 +104,7 @@ class SecondPage {
<p>
<button id="from3To2" (click)="pop()">Pop (Go back to 2nd)</button>
<button id="insert" (click)="insert()">Insert first page into history before this</button>
<button id="remove" (click)="removeSecond()">Remove second page in history</button>
</p>
<div class="yellow"><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f></div>
</ion-content>
@ -124,6 +125,10 @@ class ThirdPage {
this.nav.insert(FirstPage, 2);
}
removeSecond() {
this.nav.remove(1);
}
}