【发布时间】:2017-11-20 08:50:25
【问题描述】:
我对 Ionic 很陌生,我很难回到上一页。 错误未捕获(承诺):导航堆栈至少需要一个根。 但是在 login() 中,我将 TabsPage 推到根 (LoginPage) 上方。 使用 pop() 我想回到 LoginPage。
如果你能帮忙,我会很高兴。
这是我的代码:
myApp.ts:
export class MyApp {
rootPage:any = 'LoginPage';
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
statusBar.styleDefault();
splashScreen.hide();
});
}
}
login.ts:
public login() {
this.showLoading()
this.auth.login(this.registerCredentials).subscribe(allowed => {
if (allowed) {
this.nav.push(TabsPage);
} else {
this.showError("Email ou mot de passe incorrect");
}
},
error => {
this.showError(error);
});
}
标签:
export class TabsPage {
tab1Root = OrdersPage;
tab2Root = AboutPage;
tab3Root = ProfilePage;
/**
* @constructor
*/
constructor(private navCtrl: NavController) {}
}
profile.ts:
public logout(){
this.auth.logout().subscribe(logedout => {
if(logedout){
this.navCtrl.pop();
}
});
}
谢谢。
【问题讨论】:
-
你说的是
TabsPage,但我没有看到它的代码。 -
@Protectator 感谢您的回答。我更新了我的问题
-
我看到
tab3Root = ProfilePage;。这是否意味着您将根设置为Profile?如果是,那么这就是您无法使用pop返回的原因:配置文件现在是根。
标签: angular typescript ionic2