我有一个带下拉列表的表单:
<select class="form-control input-sm"
ng-disabled="!editMode"
ng-model="case.LawyerParticipation.LawyerID"
ng-options="lawyer.ID as lawyer.Name for lawyer in lawyers"
ng-change="changed()"></select>
默认LawyerID值为“null”。 当激活更改事件时,“更改”功能显示“case.LawyerParticipation.LawyerID”的值:
$scope.changed = function () {
alert($scope.case.LawyerParticipation.LawyerID);
};
它表明模型改变了我的预期。 $ scope.case.LawyerParticipation.LawyerID更改为我在下拉列表中选择的值。 下一步我想在服务器上发送此值。我点击提交按钮并激活“updateCase”功能:
$scope.updateCase = function () {
alert($scope.case.LawyerParticipation.LawyerID);
$http.post("/case/update", $scope.case ).success(function (updatedCase) {
$scope.case = updatedCase;
});
};
此功能中的提醒显示我可以和“LawyerID”具有新的价值。 然后“发布”发生在控制台中我看到服务器上发布的模型有LawyerID =“null”,它在服务器上也是空的!我做错了什么?为什么它是空的?
答案 0 :(得分:0)
您的服务器代码中可能会出现一些拼写错误,请将您的服务器代码添加到问题中。
$scope.updateCase = function () {
alert($scope.case.LawyerParticipation.LawyerID);
$http.post("/case/update", {data:$scope.case} ).success(function (updatedCase) {
$scope.case = updatedCase;
});
};