<ion-list>
<ion-radio ng-model="choice" ng-value="'A'" ng-click='usedGNG("yes")'>Yes</ion-radio>
<ion-radio ng-model="choice" ng-value="'B'" ng-click='usedGNG("no")'>No</ion-radio>
</ion-list>
这是我创建的两个单选按钮......现在我想使用角度js脚本选择其中一个单选按钮...我用谷歌搜索但是没有找到解决方案或者我可能没有理解正确...所以请有人帮帮我..谢谢你的帮助...
答案 0 :(得分:3)
只需在指令内或控制器中更新单选按钮的模型。
JS CODE:
angular.module('ionicApp', ['ionic'])
.controller('HomeCtrl', function($scope) {
$scope.choice = 'Ember';
});
HTML CODE:
<div ng-app="ionicApp" ng-controller="HomeCtrl">
<ion-list>
<ion-radio ng-model="choice" ng-value="'Angular'">Angular</ion-radio>
<ion-radio ng-model="choice" ng-value="'Ember'">Ember</ion-radio>
</ion-list>
<button class="button button-dark" ng-click="choice ='Angular'">
Set Angular
</button>
</div>