0
我有很多ng-repeat單選按鈕的列表。 我已經成功獲取選定的項目。 現在我嘗試設置收音機的默認值。 有人可以幫助我。這裏是我的按鈕代碼。 感謝的rnested單選按鈕的設置值
VariableRadioArr2 = [{"id":"21","libelle":"P15m","type":"radio","valeur_1":"Oui","valeur_2":"Non","valeur_3":"","valeur_4":"","valeur_5":"","valeur_6":"","valeur_7":"","valeur_8":"","valeur_9":"","valeur_10":""},{"id":"25","libelle":"Surface (m²)","type":"input","valeur_1":"","valeur_2":"","valeur_3":"","valeur_4":"","valeur_5":"","valeur_6":"","valeur_7":"","valeur_8":"","valeur_9":"","valeur_10":""},{"id":"36","libelle":"p16","type":"radio","valeur_1":"Oui","valeur_2":"Non","valeur_3":"","valeur_4":"","valeur_5":"","valeur_6":"","valeur_7":"","valeur_8":"","valeur_9":"","valeur_10":""}]
$scope.itemGroups = VariableRadioArr2;
console.log(VariableRadioArr2);
//$scope.selected = 1;
$scope.VariableRadioToggle2 = true;
$scope.clickedVariableRadio2 = function(test)
{
$scope.clickedVariableRadio2_select = JSON.parse(JSON.stringify($scope.itemGroups));
}
if(VariableRadioArr2.length == 0)
{
$scope.clickedVariableRadio2_select = [];
$scope.VariableRadioToggle2 = false;
}
<ion-list id="page-list7" ng-show="VariableRadioToggle2">
<div ng-repeat="itemGrp in itemGroups">
<ion-item class="item-divider" id="page-list-item-divider32">{{itemGrp.name}}</ion-item>
<ion-toggle name="{{itemGrp.name}}" ng-click="clickedVariableRadio2(portion.selected)" ng-repeat="(key,portion) in itemGrp.Portions" ng-model="itemGrp.selected_item" ng-true-value="'{{key}}'" ng-false-value="">{{portion.name}}</ion-toggle>
</div>
</ion-list>
'itemGrp.selected_item'應該是默認值。 – Erevald
感謝您的快速回答。我怎樣才能做到這一點 ?我已經在ng-repeat div中嘗試了ng-init =「itemGrp.selected_item」。我已經嘗試過ng-init =「itemGrp.selected_item」/ ng-value =「itemGrp.selected_item」/ ng-checked =「itemGrp.selected_item」in ion-toggle div ...但是任何工作?在控制器部分還有其他的事嗎? – JEKES
你可以修改'VariableRadioArr2'作爲子數組嗎? '[{「id」:「21」,「libelle」:「P15m」,「type」:「radio」,「values」:[{「value」:「name」,..}]} ..] ' – Erevald