私は3つのネストされたng-repeatを使ってjsonを読み込み、いくつかの質問とその回答を表示しています。それまでは動作していましたが、今は選択した回答を保存して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を置くことができますか? –
はい@マキシムスそれはここにあります:https://plnkr.co/edit/m35iYTFdh3G5v3IRghRI?p=preview – proktovief
[私の答え](http://stackoverflow.com/a/41525688/2545680)を参照してください –