当Ionic应用程序启动时,默认页面的外观
当Ionic应用程序启动时,默认页面的外观
我想将我的仪表盘页面设置为默认页面。因此在app.js中编写以下代码:$urlRouterProvider.otherwise('/app/dashboard')
。但是当ionic应用程序在移动设备上启动时,在显示登录页面之前,仪表盘页面会先出现然后消失。我希望在登录页面之前从不显示仪表盘页面。我该如何解决这个问题。
登录页面:
登录
app.js:
.state('app', { url: "/app", cache: false, abstract: true, templateUrl: "templates/app.html", controller: 'AppCtrl' }) .state('login', { url: "/login", cache: false, abstract: true, templateUrl: "templates/login.html", controller: 'LoginCtrl' }) .state('app.dashboard', { url: '/dashboard', cache: false, views: { 'menuContent': { templateUrl: 'templates/dashboard.html', controller: 'DashboardCtrl' } } }) $urlRouterProvider.otherwise('/app/dashboard');
问题出现的原因是没有使用$urlRouterProvider.otherwise('/login')
导致默认页面的出现。
解决方法是在LoginCtrl
控制器中检查用户是否已登录,然后使用$state.go('app.dashboard')
跳转到相应页面。
可能这不是最好的方法,但在这里有一个很好的答案,使用另一种方法:https://stackoverflow.com/a/32734632/2012904
我认为你对抽象属性的使用是错误的。请检查:https://stackoverflow.com/a/24969722/2012904
但像其他人说的那样,请将你的代码贴在控制器中,这样我们就可以全面理解你的问题了。