fix(tabs): popToRoot catches the rejected promise

This commit is contained in:
Manu Mtz.-Almeida
2017-02-24 17:32:53 +01:00
parent 8d9f374065
commit 738515879b
3 changed files with 14 additions and 4 deletions

View File

@@ -529,12 +529,16 @@ export class Tabs extends Ion implements AfterViewInit {
} else if (tab.length() > 1) {
// if we're a few pages deep, pop to root
tab.popToRoot();
tab.popToRoot().catch(() => {
console.debug('Tabs: pop to root was cancelled');
});
} else if (getComponent(this._linker, tab.root) !== active.component) {
// Otherwise, if the page we're on is not our real root, reset it to our
// default root type
tab.setRoot(tab.root);
tab.setRoot(tab.root).catch(() => {
console.debug('Tabs: reset root was cancelled');
});
}
}
}
@@ -545,7 +549,7 @@ export class Tabs extends Ion implements AfterViewInit {
*/
setTabbarPosition(top: number, bottom: number) {
if (this._top !== top || this._bottom !== bottom) {
const tabbarEle = <HTMLElement>this._tabbar.nativeElement;
var tabbarEle = <HTMLElement>this._tabbar.nativeElement;
tabbarEle.style.top = (top > -1 ? top + 'px' : '');
tabbarEle.style.bottom = (bottom > -1 ? bottom + 'px' : '');
tabbarEle.classList.add('show-tabbar');

View File

@@ -315,6 +315,11 @@ export class Tab2Page3 {
constructor(public navCtrl: NavController) {}
ionViewCanLeave() {
console.log('Tab2Page3, ionViewCanLeave', false);
return false;
}
ionViewWillEnter() {
console.log('Tab2Page3, ionViewWillEnter');
}

View File

@@ -4,8 +4,9 @@
<h2>Tab 2, Page 3</h2>
<p>No Header.</p>
<p>This page can't be left</p>
<p><button ion-button (click)="navCtrl.pop()">Back to Tab 2, Page 2</button></p>
<p><button ion-button navPop>Back to Tab 2, Page 2</button></p>
<div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div>
<div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div>