Angular BaQend-DBready在初始化时,检查用户的登录状态
我正在与BaQend&Ionic2合作,试图在应用程序启动时获得一些任务 1。DBready 我不想在每一页都这样做:Angular BaQend-DBready在初始化时,检查用户的登录状态,angular,typescript,ionic-framework,app-startup,baqend,Angular,Typescript,Ionic Framework,App Startup,Baqend,我正在与BaQend&Ionic2合作,试图在应用程序启动时获得一些任务 1。DBready 我不想在每一页都这样做: ionViewCanEnter(): Promise<baqend> { // Check if the Baqend SDK is ready and wait for initialization return this.ready.resolve().then(db => this.db = db); } 2。检查用户登
ionViewCanEnter(): Promise<baqend> {
// Check if the Baqend SDK is ready and wait for initialization
return this.ready.resolve().then(db => this.db = db);
}
2。检查用户登录状态
在应用程序启动时,我应该检查用户的登录状态,如果他/她没有登录,它应该打开LoginModel
ionViewWillEnter(){
if (this.db.User.me) {
console.log(this.db.User.me.username,' entered HomePage with ID ', this.db.User.me.id);
} else {
this.openLoginModal()
console.log('Hello Anonymous');
}
}
这是rootPage的工作代码,但最好将其放入应用程序启动中
有什么想法吗?很好
我们已经更新了离子起动器。我们将DBReady检查移动到根视图。
在我们的初学者中是tabs.component.ts。然后Rootview在呈现子视图之前总是等待db
如果您也更新了,那么现在还可以使用从SDK导出的db
import { db } from "baqend";
您能否澄清initializeApp()来自何处?来自“app/app.component.ts”以及我如何实现登录检查?登录检查也可以在根视图中实现。是否有方法将其实现到app.component.ts中?我不使用标签,我只使用侧菜单。
import { db } from "baqend";