我正在尝试更新特定用户的详细信息,并且它不断给出错误,即脚本中未定义memberID。我该怎么写呢?已经尝试过膜,但仍然给了我同样的错误。谢谢你的帮助
Members.controller('editMembers',['$scope','$http','$routeParams',function($scope, $http,$routeParams){
var id=$routeParams.id;
console.log(id);
$scope.updateMember="";
//populating data with exsisting member details
$http.post('PHP/getMemberByID.php',{'id':id}).success(function(data){
$scope.memb=data;
console.log(data);
});
$scope.updateMember = function(project) {
$http.post('PHP/editMembers.php/'+id, memberID).success(function(data) {
if (data) {//row updated
console.log("Succesful Update");
} else {
console.log("Unsuccesful Update");
}
});
};
}]);
答案 0 :(得分:1)
传递函数中的memberID代替项目
$scope.updateMember = function(memberID) {
$http.post('PHP/editMembers.php/'+id, memberID).success(function(data) {
if (data) {//row updated
console.log("Succesful Update");
}
else {
console.log("Unsuccesful Update");
}
});
};
或者如果memberID在项目集合中,那么就像
一样$scope.updateMember = function(project) {
$http.post('PHP/editMembers.php/'+id, project.memberID).success(function(data) {
if (data) {//row updated
console.log("Succesful Update");
}
else {
console.log("Unsuccesful Update");
}
});
};