登录完成后无法正确重定向 [英] cant redirect correctly after login is done
本文介绍了登录完成后无法正确重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试像以下示例中那样执行登录页面:
https:// github.com/keithdmoore/ionic-http-auth
我有2个问题:
I am trying to do login page like in example here: https://github.com/keithdmoore/ionic-http-auth I have 2 issues:
1.尝试重新启动应用页面时出现错误
1.getting error when trying to redrect to app page
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');
});
app:
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})
.state('app.placeslists', {
url: "/placeslists",
cache: false,
views: {
'menuContent': {
templateUrl: "templates/placeslists.html",
controller: 'PlaceslistsCtrl'
}
}
})
2.第二个问题看起来像gui的一些问题,我试图列举登录模板的列表示例但是它看起来不像离子成分的例子。
我的模板
2.the second issue looks like some issue with gui, I tryed to take list examples of login templates but it isnt looks like examples from ionic components. my template
<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>
推荐答案
只需导航到主页或其他内容,所以:
Simply navigate to the homepage or something, so:
.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');
});
这篇关于登录完成后无法正确重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文