0
我有一個使用ng-token-auth的Ionic應用程序。它使用2 ng-token-auth配置,用於具有不同身份驗證apis的2組用戶。Ionic AngularJS重定向如果已經過身份驗證
app.js
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'templates/home/home.html',
controller: 'HomeCtrl'
})
.state('employee', {
url: "/employee",
templateUrl: "templates/employee.html",
controller: 'EmployeeCtrl'
})
.state('employer', {
url: "/employer",
templateUrl: "templates/employer.html",
controller: 'EmployerCtrl'
})
$urlRouterProvider.otherwise('/home');
HomeCtrl
$scope.$on('$ionicView.beforeEnter', function(){});
我現在把認證在$ ionicView.beforeEnter檢查,但它閃爍的主屏幕,然後重定向到正確的頁面。有沒有更好的地方來說明這一點。由於
這將是$ urlRouterProvider.otherwise我的默認狀態( '/ home'),因爲我有僱員和僱主? –
如果我瞭解您的應用程序正確,則應首先加載本地狀態,您可以根據決定選擇是否重定向到員工或僱主狀態。 –