我正在使用Ionic单选按钮。我的代码:
<div class="item">
<span class="input-label">Category : </span>
<ion-radio ng-model="cssPre" ng-value=0>Saroj</ion-radio>
<ion-radio ng-model="cssPre" ng-value=1>Sadhana</ion-radio>
<ion-radio ng-model="cssPre" ng-value=2>Neha</ion-radio>
</div>
<div class="item">
<span class="input-label">Work Place : </span>
<ion-radio ng-model="workplace" ng-value="0">At clinic</ion-radio>
<ion-radio ng-model="workplace" ng-value="1">At center</ion-radio>
</div>
当我点击第一组时,它可以正常工作,但只要我从第二组中选择一个工作地点,我选择的类别就会消失。
答案 0 :(得分:0)
您的代码正常,take a look to this codepen:
<div class="item">
<span class="input-label">Category: </span><br />
<span>Selected Value: {{cssPre}}</span>
<ion-radio name="cssPre" ng-model="cssPre" ng-value="0">Saroj</ion-radio>
<ion-radio name="cssPre" ng-model="cssPre" ng-value="1">Sadhana</ion-radio>
<ion-radio name="cssPre" ng-model="cssPre" ng-value="2">Neha</ion-radio>
</div>
<div class="item">
<span class="input-label">Work Place : </span> <br />
<span>Selected Value: {{workplace}}</span>
<ion-radio name="workplace" ng-model="workplace" ng-value="0">At clinic</ion-radio>
<ion-radio name="workplace" ng-model="workplace" ng-value="1">At center</ion-radio>
</div>
我只在第一个广播组中添加了引号,并添加了每个组的选定值。
更新:我为每个离子收音机添加了name
属性并修复了codepen demo。