1
我試圖建立一個登記的意見,但我的問題是,如果用戶已經註冊的檢查語句將執行在$ionicPlatform.ready
,如下所示:離子登記觀點
$ionicPlatform.ready(function() {
db = $cordovaSQLite.openDB({ name: "my.db" });
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS groups (id integer primary key, title text)");
if (typeof(Storage) != "undefined") {
// Store
var registered = localStorage["isRegistered"];
if(registered == undefined || !registered){
$location.path('/register');
}else{
$location.path('/tab/groups');
}
}
});
的問題是, $urlRouterProvider.otherwise('/tab/groups')
預成型件在離子準備就緒之前,這意味着在應用程序首次打開時,它會顯示組選項卡,然後進入註冊視圖。 我試圖把語句檢查,如果用戶在其他方式已註冊類似如下:
$urlRouterProvider.otherwise(function($injector, $location){
if (typeof(Storage) != "undefined") {
// Store
var registered = localStorage["isRegistered"];
if(registered == undefined || !registered){
$location.path('/register');
}else{
$location.path('/tab/groups');
}
} });
另外,我面對我們到達組選項卡(獲得團體從數據庫)另一個問題,我們打開前數據庫中的離子準備好了。 有沒有解決方案來完成註冊?
使默認爲寄存器視圖 –
這不是一個很好的解決方案,此外,如果用戶已經註冊,他會看到註冊視圖直到離子準備就緒 –
更好地使用一些啓動畫面,然後在yourApp.run()方法中根據註冊狀態更改路由。 –