2016-09-18 45 views
0

這是我的看法離子如何在Ionic視圖中創建和檢索ng-repeat中的ng-model值?

<div class="divTable" ng-repeat="quest in Questions" > 
    <div class="divTableBody"> 
    <div class="divTableRow"> 
    <div class="divTableCell" ><strong>{{quest.no}}.</strong></div> 
    <div class="divTableCell" style="width:100%"><strong>{{quest.question}}</strong></div> 
    </div> 
    <div class="divTableRow" ng-repeat="choice in quest.jawaban" > 
    <div class="divTableCell">&nbsp;</div> 
    <div class="divTableCell"><input type="radio" ng-value="'{{choice.jawaban}}'" name="{{quest.no}}" id="{{choice.jawaban}}"><label for="{{choice.jawaban}}">{{choice.jawaban}}</label></div> 
    </div> 
    <br> 
    </div> 
    </div> 

如何獲得控制單選按鈕值..?

謝謝

+0

你可以更新你的控制器,json數據並提及ng-model的值 – Dhaarani

回答

0

如何:

<input type="radio" ng-model="data" ng-value="'{{choice.jawaban}}'" name="{{quest.no}}" id="{{choice.jawaban}}"> 

在控制器:

$scope.data = "start"; //will be the first selected, has to match any value 

然後,您可以用$ scope.data你的率性或觀看更改。

+0

測試到控制檯,結果是undefined –

+0

也許和這個codepen相比:https://codepen.io/ionic/pen/saoBG –