从服务器端重定向到URL

时间:2014-11-06 15:27:41

标签: javascript angularjs node.js

我正在登录,登录成功后,我想显示仪表板屏幕。

但是,成功登录后,仪表板页面不会显示。页面不刷新,登录页面仍然存在。没变。

请帮我重定向到信息中心网址:

Angular JS代码

function loginctrl($scope, $http) {
$scope.login = function() {
    emp_url = '/login';
    emp_msg = "SUCCESSFULLY SIGN Up";

    $http.post(emp_url, $scope.formData).success(function(data) {                       
    });
};

}

Node.js代码

 app.get('/dashboard', isLoggedIn, function(req, res){  
    res.sendfile('./public/template-home.html', {user : req.user});     
});

app.post('/login', passport.authenticate('local-login', {
    successRedirect : '/dashboard', // redirect to the secure dashboard section
    failureRedirect : '/login', // redirect back to the signup page if there is an error
    failureFlash : true // allow flash messages
}));

1 个答案:

答案 0 :(得分:0)

在这里回答:Nodejs Redirect URL

或者您可以在传递给.success

的函数中使用前端的$ location

$ location的角色文档:https://docs.angularjs.org/api/ng/service/$location

相关问题