我试图从收音机列表中的单选按钮中选中一个,但没有运气。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