从后面的历史记录中删除视图 - Ionic2 [英] Remove a view from the back history - Ionic2

查看:121
本文介绍了从后面的历史记录中删除视图 - Ionic2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何从ionic2中的后历史(或导航堆栈)中删除视图?

Anyone knows how to remove a view from the back history (or navigation stack) in ionic2?

在Ionic 1中,我用

In Ionic 1 I solved this with

this.$ionicHistory.nextViewOptions({
  disableAnimate: true, 
  disableBack: true
});

例如,从历史记录中完全删除我的应用程序的登录页面会非常有用已成功登录。

Would be really useful, for example, to fully remove the login page of my application from the history once a successfully login was performed.

在这种情况下,只是没有显示后退按钮是不够的,因为Android终端在设备上有自己的物理后退按钮。

Just not showing the back button isn't enough in such case, since Android terminals got their own physical back button on the devices.

我尝试了,在我的登录功能返回成功的承诺之后,在推送堆栈中的下一页之前:

I tried, after my login function returned a successful promise and before pushing the next page in the stack:

this.navController.pop();

this.navController.remove(this.viewCtrl.index);

但遗憾的是两者都没有成功:(

but unfortunately both weren't successful :(

推荐答案

https://forum.ionicframework.com/t/solved-disable-back-in-ionic2/57457 找到解决方案

this.nav.push(TabsPage).then(() => {
  const index = this.nav.getActive().index;
  this.nav.remove(0, index);
});

所以我想推送下一页很重要首先,等待承诺答案,然后删除当前视图

so I guess it's important to push the next page first, wait for the promise answer and then remove the current view

这篇关于从后面的历史记录中删除视图 - Ionic2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆