mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
feat(nav-controller): remove method
This commit is contained in:
@ -335,6 +335,26 @@ export class NavController extends Ion {
|
|||||||
return Promise.resolve();
|
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.
|
* Set the view stack to reflect the given component classes.
|
||||||
* @param {TODO} components TODO
|
* @param {TODO} components TODO
|
||||||
|
@ -437,9 +437,7 @@ class Pane {
|
|||||||
|
|
||||||
showNavbar(hasNavbar) {
|
showNavbar(hasNavbar) {
|
||||||
this.navbar = hasNavbar;
|
this.navbar = hasNavbar;
|
||||||
if (!hasNavbar) {
|
this.renderer.setElementAttribute(this.elementRef, 'no-navbar', hasNavbar ? null : '' );
|
||||||
this.renderer.setElementAttribute(this.elementRef, 'no-navbar', '');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,7 @@ class SecondPage {
|
|||||||
<p>
|
<p>
|
||||||
<button id="from3To2" (click)="pop()">Pop (Go back to 2nd)</button>
|
<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="insert" (click)="insert()">Insert first page into history before this</button>
|
||||||
|
<button id="remove" (click)="removeSecond()">Remove second page in history</button>
|
||||||
</p>
|
</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>
|
<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>
|
</ion-content>
|
||||||
@ -124,6 +125,10 @@ class ThirdPage {
|
|||||||
this.nav.insert(FirstPage, 2);
|
this.nav.insert(FirstPage, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeSecond() {
|
||||||
|
this.nav.remove(1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user