我試圖從收音機列表中的單選按鈕中選中一個,但沒有運氣。Ionic + Angular無法默認檢查離子收音機
有人能告訴我我做錯了什麼嗎?
感謝您的任何幫助。
我試圖通過這種方式來做到這一點:
<div class="list">
<ion-radio ng-repeat="item in goalTypeList"
ng-value="item.value"
ng-change="goalTypeChanged(item)"
ng-checked="item.selected"
ng-model="data.clientSide">
{{ item.text }}
</ion-radio>
</div>
JS:
.controller('SettingsCtrl', function($scope, $ionicLoading) {
$scope.goalTypeList = [
{ text: "Dials", value: "dials", selected: true },
{ text: "Conversations", value: "conversations" , selected: false },
{ text: "Appointments", value: "appointments" , selected: false },
{ text: "Orders", value: "orders", selected: false }
];
$scope.data = {
clientSide: 'ng'
};
$scope.goalTypeChanged = function(item) {
console.log("Selected goalType, text:", item.text, "value:", item.value);
};
謝謝,但我不知道怎麼傳遞到$ scope.data? – 2014-09-25 14:14:43
將$ scope.data中的clientSide值設置爲無論您想要作爲單選按鈕上選定的默認值。如果你不想在默認情況下選擇任何設置clientSide ='' – 2014-09-25 14:55:38