我想将已检查的单选按钮值以角度
发送到服务器我试过,但我收到500服务器错误
当我只发送正在运行的问题ID时
这是CreateController的代码
var CreateController = ['$scope', '$http', function ($scope, $http) {
$scope.mydata = 'ajs works';
$scope.model = {
Questions:{}
};
$http.get('/Testing/IndexVM').success(function (newdata) {
$scope.model = newdata;
});
$scope.NextQuestion = function () {
$http.post('/Testing/NextQuestion', {
quid: $scope.model.Questions.AddQuestionID, selectedopt: $scope.model.Questions.Options.OptionID
}).success(function (newdata) {
$scope.model = newdata;
});
}];
以下是我要发送的索引视图的代码
<div ng-controller="CreateController">
<tr>
<td>
<h3>Question: {{model.Questions.Question}}</h3>
</td>
</tr>
<tr ng-repeat="item in model.Questions.Options" ng-model="model.Questions.Options.OptionID">
<td class="switch radius">
<input id="{{item.Options}}" type="radio" name="selectedvalue" value="{{item.Options}}">
<label for="{{item.Options}}"></label>{{item.Options}}
</td>
</tr>
</div>
答案 0 :(得分:1)
将ng-model移动到input元素,这样每个单选按钮都具有与具有单选按钮组相同的ng-model和相同的name属性,并且模型具有所选值属性的值
所以ng-model =&#34; model.Questions.Options.OptionID&#34;不是&#34;项目&#34;
答案 1 :(得分:0)
在单选按钮中添加ng-model:
<input id="{{item.Options}}" type="radio" name="selectedvalue" value="{{item.Options}} ng-model="item">