我想製作一個問卷,我可以直接在應用程序的變量中填充,因爲我在這個小項目中沒有任何數據庫。問卷由20個問題組成,我使用單選按鈕選擇答案。在問卷調查的結束,我必需要顯示選定的答案,爲了這個,我做的範圍對象的TestResult角度數組和ng-repeat比率組
起初,我在想手工填寫的所有20個問題和無線電變量,但我看到了一個NG-重複角度功能可能有幫助,並且想知道在這種情況下是否可以使用它。
我可能將每個無線電組的初始值存儲在數組中,然後使用ng-repeat將它們打印在視圖中。我真的不知道從哪裏開始。
接下來是一段與我的項目相關的代碼。
查看
<div class="form-group">
<div class="radio">
<label><input type="radio" name="qs01" ng-model="testResult.qs01" value="1">
Question One.
</label>
</div>
<div class="radio">
<label><input type="radio" name="qs01" ng-model="testResult.qs01" value="2">
Question Two.
</label>
</div>
<div class="radio">
<label><input type="radio" name="qs01" ng-model="testResult.qs01" value="3">
Question Three.
</label>
</div>
<div class="radio">
<label><input type="radio" name="qs01" ng-model="testResult.qs01" value="4">
Question Four.
</label>
</div>
<div class="radio">
<label><input type="radio" name="qs01" ng-model="testResult.qs01" value="5">
Question Five.
</label>
</div>
</div>
應用
// Test Result Object
$scope.testResult = {};
我需要重申的是:
<div class="radio">
<label><input type="radio" name="qs01" ng-model="testResult.qs01" value="Question Variable">
Question Variable
</label>
</div>
謝謝你的幫助,我嚐到了它的作品,只是...我注意到所有的比例都處於相同的位置。我想要實現的是重複包含每個廣播的所有方框,並使用重複選項更改標籤和變量。這可以用同樣的方式進行嗎? **我更新了問題,如果你想看看。** –
我明白了!它的工作原理是:D ...我移動了ng-repeat,並在無線電容器中工作。這是我使用的代碼: '