Routing 登录完成后无法正确重定向
我正在尝试登录页面,如以下示例所示: 我有两个问题: 1.尝试重定向到应用程序页面时出错Routing 登录完成后无法正确重定向,routing,ionic,Routing,Ionic,我正在尝试登录页面,如以下示例所示: 我有两个问题: 1.尝试重定向到应用程序页面时出错 Error: Cannot transition to abstract state 'app' 守则: .controller('LoginCtrl', function ($scope, $state, AuthenticationService) { $scope.message = ""; $scope.user = { username: null,
Error: Cannot transition to abstract state 'app'
守则:
.controller('LoginCtrl', function ($scope, $state, AuthenticationService) {
$scope.message = "";
$scope.user = {
username: null,
password: null
};
$scope.login = function () {
AuthenticationService.login($scope.user);
};
$scope.$on('event:auth-loginRequired', function (e, rejection) {
console.log('handling login required');
$scope.loginModal.show();
});
$scope.$on('event:auth-loginConfirmed', function () {
$scope.username = null;
$scope.password = null;
$state.go('app');
});
应用程序:
2.第二个问题看起来像是gui的一些问题,我尝试了登录模板的列表示例,但它不像来自ionic组件的示例。
我的模板
<ion-view>
<ion-content>
<div class="list" ng-controller="LoginCtrl">
<label class="item item-input">
<input type="text" placeholder="Username" ng-model="user.username" required>
</label>
<label class="item item-input">
<input type="password" placeholder="Password" ng-model="user.password" required>
</label>
</div>
</ion-content>
</ion-view>
关于问题1,我在github上看到了以下
$scope.loginModal.hide()代码>
而不是您的代码:$state.go('app')代码>
关于第2期,您应该查看,,,
,只需导航到主页或其他内容,因此:
.state('app.home', {
url: "/home",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/home.html"
}
}
})
$scope.$on('event:auth-loginConfirmed', function () {
$scope.username = null;
$scope.password = null;
$state.go('app.home');
});
对于问题1,我的AppCtrl上没有代码,因为我需要执行路由。对于2个问题,我添加了,但仍然有相同的问题。对于gui问题,您是对的,它确实解决了问题。但是关于另一个,当您将$state.go('app')替换为$scope.loginModal.hide()时,结果是什么?问题是什么?.controller('AppCtrl',function($scope,$state,$ionicModal){}这是我的控制器应用程序及其空$ionicModal.fromTemplateUrl('templates/login.html',function(modal){$scope.loginModal=modal;},{scope:$scope,animation:'slide up',focusFirstInput:true});
.state('app.home', {
url: "/home",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/home.html"
}
}
})
$scope.$on('event:auth-loginConfirmed', function () {
$scope.username = null;
$scope.password = null;
$state.go('app.home');
});