[英]How can I create a login page using Ionic 2 framework that then leads to a tabbed view?
Currenty, in my app.html
file, I have: Currenty,在我的app.html
文件中,我有:
<ion-tabs>
<ion-tab [root]="tab1Root" tabTitle="Tab1" tabIcon="time"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="Tab2" tabIcon="paper"></ion-tab>
<ion-tab [root]="tab3Root" tabTitle="Tab3" tabIcon="more"></ion-tab>
</ion-tabs>
and in my app.js
file, after doing the proper imports of these pages, I have: 在我的app.js
文件中,在正确导入这些页面后,我有:
this.tab1Root = Page1;
this.tab2Root = Page2;
this.tab3Root = Page3;
I want the application to open with a login page, and then from there progress to this tabbed view. 我希望应用程序打开一个登录页面,然后从那里进展到这个选项卡视图。 I'm not sure how to logically set this up in the context of app.html
and app.js
我不确定如何在app.html
和app.js
的上下文中进行逻辑设置
I'm only interested in answers involving Ionic 2 (and Angular 2+), not the older versions. 我只对涉及Ionic 2(和Angular 2+)的答案感兴趣,而不是旧版本。
In your app, define this: 在您的应用中,定义以下内容:
export class YourApp {
rootPage: Type = LoginPage;
constructor(app: IonicApp, platform: Platform) {
platform.ready().then(() => {
});
}
}
In your LoginPage, it should have this: 在您的LoginPage中,它应该具有:
export class LoginPage {
constructor(nav: NavController) {
this.nav = nav;
}
doLogin() {
if (loginSuccessful) {
this.nav.setRoot(YourTabsPage);
}
}
}
if your app is always opening with login page, you should: 如果您的应用始终以登录页面打开,您应该:
1- Put your login page in app.html 1-将您的登录页面放在app.html中
2- Import and inject NavController in your app.js constructor. 2-在app.js构造函数中导入并注入NavController 。
import {NavController} from 'ionic-framework/ionic';
constructor(nav: NavController) {
this.nav = nav;
}
3- Create a new Tabs parent component. 3-创建新的Tabs父组件。 ( your current app.js ) and call it TabsParentComponent for example. (您当前的app.js)并将其称为TabsParentComponent。
4- In app.js, once the login is successful, call: 4-在app.js中,一旦登录成功,请致电:
this.nav.setRoot(TabsParentComponent)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.