【发布时间】:2016-11-11 15:54:59
【问题描述】:
我的$ionicModals 有点问题。每次我打开一个模式时,它都会强制一条空路线导致$urlRouterProvider.otherwise('/login'); 发生。如果我从我的配置中取出$urlRouterProvider,它工作正常——但是我的应用程序只是启动到一个空白屏幕。有谁知道是什么导致了这个问题?我在FeedController 中非常标准地称呼离子模态:
$ionicModal.fromTemplateUrl('templates/views/view.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.modal.show().then(function() {
// Blah
});
我的配置如下所示:
$stateProvider
.state('login', {
url: '/login',
templateUrl: 'templates/login.html',
controller: 'LoginController',
resolve: {
'currentAuth': function(Auth) {
return Auth.checkAuth().$waitForAuth();
},
'clearCache': function($ionicHistory) {
return $ionicHistory.clearCache();
}
}
})
.state('app', {
url: '/app',
abstract: true,
templateUrl: 'templates/main.html',
controller: 'SideMenuController',
resolve: {
'currentAuth': function(Auth) {
return Auth.checkAuth().$waitForAuth();
}
}
})
.state('app.feed', {
url: '/feed',
views: {
'viewContent': {
templateUrl: 'templates/views/feed.html',
controller: 'FeedController',
resolve: {
'currentAuth': function(Auth) {
return Auth.checkAuth().$requireAuth();
},
'clearCache': function($ionicHistory) {
return $ionicHistory.clearCache();
}
}
}
});
$urlRouterProvider.otherwise('/login');
});
我还应该提到我正在解决在状态加载之前检查 AngularFire 身份验证。我正在收听$rootScope 以查看是否有$stateChangeError,然后这会将用户重定向到登录屏幕,但这似乎不是问题,因此删除了$urlRouterProvider 行:
$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {
if (error === 'AUTH_REQUIRED') {
$state.go('login');
}
});
我还清除了FeedController 和LoginController 解析上的缓存。有没有人遇到过 $ionicModals 的这个问题?如果您能提供帮助,请告诉我。非常感谢。
【问题讨论】:
标签: angularjs ionic-framework firebase angularfire firebase-authentication