javascript - MEAN.js - 登录后重定向用户 - 在本地工作,但在部署时不起作用

标签 javascript meanjs

我尝试在注册后重定向用户,但无论出于何种原因它在本地运行而不是在部署时运行

这是该函数,$window.location.href = '/settings/picture'; 在部署时无效

$scope.signup = function (isValid) {
  $scope.error = null;

  if (!isValid) {
    $scope.$broadcast('show-errors-check-validity', 'userForm');

    return false;
  }

  $http.post('/api/auth/signup', $scope.credentials).success(function (response) {
    // If successful we assign the response to the global user model

    $scope.authentication.user = response;

    // And redirect to avatar selection screen
    $window.location.href = '/settings/picture'; 


  }).error(function (response) {
    $scope.error = response.message;
  });
};

最佳答案

您可以尝试在 post('/api/auth/signup') 路由中使用 res.render('/settings/picture', {title: another title}) 而不是使用 $ Controller 中的 window.location.href

或者尝试提供完整的地址,例如 $window.location.href = "http://domain.com/settings/pictures.html "

关于javascript - MEAN.js - 登录后重定向用户 - 在本地工作,但在部署时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36903147/

相关文章:

javascript - 图像 src - 使用 meanjs 获取 404 错误

angularjs - meanjs 路由到服务器 Controller

javascript - 在 jQuery 中减慢 location.reload()?

javascript - 如何让鼠标悬停在我想要的范围内工作?

javascript - jquery 选择所有不包含特定文本的行

html - 如何在输入字段中使用 typeahead 来获取 Angularjs 中的值?

meanjs 通过 userid 查找 crud 模块的结果

javascript - 动态加载/卸载 javascript 和 css 样式表有优势吗?

javascript - 仅在 html 打印中删除/隐藏最后一页

angularjs - 具有依赖项的 registerModule