javascript – 登录后重定向
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – 登录后重定向,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1490字,纯文字阅读大概需要3分钟。
内容图文
![javascript – 登录后重定向](/upload/InfoBanner/zyjiaocheng/745/a7830d400dd0434d9907cd96b3345196.jpg)
我的应用程序中有重定向问题.这些是我的州提供者:
testApplication.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})
.state('app2', {
url: "/app2",
abstract: true,
templateUrl: "templates/menu2.html",
controller: 'AppCtrl'
})
.state('app2.login', {
url: "/login",
views: {
'menuContent': {
templateUrl: "templates/login.html",
controller: 'LoginCtrl'
}
}
})
.state('app.profile', {
url: "/profile",
views: {
'profile' :{
templateUrl: "templates/profile.html",
controller: "ProfileCtrl"
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app2/login');
});
我的AppCtrl为空,这是我的LoginCtrl:
testApplication.controller('LoginCtrl', function($scope, $location){
$scope.fbLogin = function() {
openFB.login( function(response) {
if (response.status === 'connected') {
// This runs on success
console.log('Facebook login succeeded');
$scope.$apply( function () { $location.path('profile') } );
} else {
alert('Facebook login failed');
}
}, {scope: 'email,publish_actions,user_friends'}
);
};
})
问题是登录后我没有被重定向.但如果我改变
$urlRouterProvider.otherwise('/app2/login');
至
$urlRouterProvider.otherwise('/app/profile');
然后手动转到“#/ app2 / login”登录我会被重定向到个人资料页面.我该如何解决这个问题?
解决方法:
尝试
$state.go('app.profile')
代替
$scope.$apply( function () { $location.path('profile') } );
我希望这对其他人也有帮助.
内容总结
以上是互联网集市为您收集整理的javascript – 登录后重定向全部内容,希望文章能够帮你解决javascript – 登录后重定向所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。