如何在Angular Js和IonicFramework项目中登录后将用户重定向到上一页 [英] How to redirect user to previous page after login in Angular Js and IonicFramework project

查看:119
本文介绍了如何在Angular Js和IonicFramework项目中登录后将用户重定向到上一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个离子框架项目,该项目允许用户查看订阅源和描述,但是如果用户未登录,则只要用户单击评论发送按钮,用户就会将用户重定向到登录页面。如何在以下情况下获得之前的状态登录页面,以便登录成功后,用户被重定向到previos页面?

I am working on an ionicframework project which allows user to view feeds and description but redirects the user to login page whenever the user clicks comment send button if the user is not logged in. How do I get the previous state when in the login page so that after login is successful the user is redirected to the previos page?

推荐答案

修改你的运行

run(['$rootScope', function($rootScope) {
    $rootScope.$on('$locationChangeStart', function() {
        $rootScope.previousPage = location.pathname;
    });
}]);

当您从请求中得到答案时,您将重定向到$ rootScope.previousPage

When you get answer from your request you redirect to $rootScope.previousPage

这篇关于如何在Angular Js和IonicFramework项目中登录后将用户重定向到上一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆