$ http.put('')不反映页面重新加载(MEAN)上的更改

时间:2015-10-17 20:47:32

标签: javascript angularjs node.js mongodb express

下面是我的控制器的代码。代码正确地将编辑的工资保存在我的mongodb数据库中,它将反映页面上的更改。但是,在页面重新加载时,页面显示了工资的旧值,并且这样做直到我将用户注销并重新登录。有关如何解决此问题的任何想法?

$http.get('http://localhost:3000/user').success(function(user) {
  console.log("user", user);
  $scope.user = user;
  $scope.currentUser = user.displayName;
  $scope.salary = user.salary;
});

$scope.openMoneyEdit = function() {
  $scope.salary = $scope.user.salary;
  matchId = $scope.user._id;
  console.log(matchId);
};
$scope.editMoney = function(user) {
  $http.put('/money/' + $scope.user._id, user)
  .success(function(response) {
    if (response === 'fail'){
      alert('Fail to edit ', 'Make sure year format is correct', 'error');
    } else {
      alert('Success', 'info updated.', 'success');
    }
  }).catch(function(err) {
    console.log(err);
  });
};

0 个答案:

没有答案