json을 읽으려면 3 개의 중첩 된 반복을 사용하고 몇 가지 질문과 답변을 표시하십시오. 지금까지는 작동하지만 지금은 선택 응답을 저장하고 API로 보내려고합니다. 선택한 답변이 저장되지 않은 이유를 모르겠습니다. AngularJS : 양식에서 값을 얻으십시오.
이
내이다 :<form>
<div class="panel panel-default" ng-repeat="section in questionsTest">
<div class="panel-heading">
<h1>{{ section.name }}</h1>
<h3 class="panel-title">{{ section.name }}. {{
section.description }}</h3>
</div>
<div class="panel-body" ng-repeat="question in section.questions">
{{ question.statement }}
<div ng-repeat="answer in question.answers">
<!-- <label class="radio-inline"> <input type="{{ answer.type }}" ng-model="question.value"
name="{{ answer.id }}" id="{{ answer.id }}" value="{{ answer.id }}">
{{ answer.valor }}
</label>-->
<label class="radio-inline"> <input type="{{ answer.type }}" ng-model="question.valor"
name="{{ question.id }}" id="{{ answer.id }}" value="{{ answer.id }}">
{{ answer.valor }}
</label>
</div>
</div>
</div>
</form>
그리고 이것은 컨트롤러 :
$scope.question = {};
$scope.testing = function(){
console.log($scope.question);
};
$의 scope.testing 콘솔에 $ scope.question
의 가치를 볼 수있는 테스트 기능입니다
당신은 plunker을 넣을 수 있습니다? –
예 @ Maximus 여기 있습니다 : https://plnkr.co/edit/m35iYTFdh3G5v3IRghRI?p=preview – proktovief
[내 대답] (http://stackoverflow.com/a/41525688/2545680)을 참조하십시오. –