角度检查单选按钮值发送到服务器

时间:2015-01-07 08:34:25

标签: javascript asp.net-mvc angularjs

我使用http.post

从服务器调用问题

我想从我从http.get

获得的数据中传递选定的optionid

请告诉我该怎么做

这是CreateController.js的代码

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}).success(function (newdata) {

            $scope.model.Questions.push(newdata);

        });


    };
    //delete $http.defaults.headers.common['X-Requested-With'];


}];

这是视图

<h2></h2>

<div ng-controller="CreateController">
    <table class="ui-sortable-handle">
        <tr>
            <td>
                <input type="hidden" id="qid" ng-model="model.Questions.AddQuestionID" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="hidden" id="complevel" ng-model="model.Questions.ComplexityLevel" />
                <input type="hidden" id="servcomplvl" ng-model="model.servercomplevel" />
            </td>
        </tr>
        <tr>
            <td>
                <h3>Question: {{model.Questions.Question}}</h3>
            </td>
        </tr>
        <tr ng-repeat="item in model.Questions.Options">
            <td class="switch radius">
                <input id="{{item.Options}}" type="radio" name="selectedvalue" value="{{item.Options}}">
                <label for="{{item.Options}}"></label>{{item.Options}}
            </td>
        </tr>

    </table>
    {{mydata}}


    <div class="nav-bar right">
        <ul class="button radius" id="myButton"  ng-click="NextQuestion()">Next</ul>
    </div>


    <div>

    </div>

    <div></div>
</div>

0 个答案:

没有答案
相关问题