所以我試圖從離子1開始使用離子2,並且需要一些關於如何在我的項目中設置驗證的指導。具體來說,我使用的是Firebase和angularfire2。如何在離子2中實現登錄流程?
作爲一般方法,我應該:
a。檢查app.ts上的session/localStorage並設置rootPage以在未經身份驗證的情況下登錄?如果我將用戶登出並將導航根頁面設置回登錄,則使用此方法,這些標籤顯示在底部。
灣創建登錄頁面作爲一種模式,它可以消除底部出現的選項卡問題,但我不確定是否應該從app.ts發射模式,因爲我不確定應用程序本身是否具有根視圖我應該參考。
另外,我要建立權威性的登錄和註銷的服務和重構出來,而不是在登錄頁面和註銷按鈕在配置控制器擁有它?
這是我的邏輯迄今使用方法A:
app.ts
export class MyApp {
rootPage: any;
local: Storage = new Storage(LocalStorage);
constructor(platform: Platform) {
this.local.get('user').then(user => {
if (user) {
this.rootPage = TabsPage;
} else {
this.rootPage = LoginPage;
}
});
platform.ready().then(() => {
StatusBar.styleDefault();
});
}
}
而在myProfile.ts
logout() {
this.local.remove('user');
this.user = null;
let modal = Modal.create(LoginPage);
this.nav.present(modal); //should I set the rootPage instead? if so how do I remove the tabBar or set the rootpage of the containing app root page
}
我在這個問題你問已經給出了答案http://stackoverflow.com/questions/36530765/how-to-set-up-firebase-with-ionic-2-angular-2-and-typescript –