Ionic 2中的两个单选按钮

时间:2018-09-01 12:56:46

标签: angular ionic2

如何将其翻译为Ionic 2?

<div class="weightunitradios">
  <ion-checkbox 
    class="checkboxes" 
    ng-model="data.weightunit" 
    ng-true-value="'kg'" 
    ng-false-value="'lbs'" 
    ng-change="saveWeightUnit(); changeMinMax(); convertWeightInput(); saveUserWeight();">
    kg
  </ion-checkbox>
  <ion-checkbox 
    class="checkboxes" 
    ng-model="data.weightunit" 
    ng-true-value="'lbs'" 
    ng-false-value="'kg'" 
    ng-change="saveWeightUnit(); changeMinMax(); convertWeightInput(); saveUserWeight();">
    lbs
  </ion-checkbox>
</div>

我尝试了此操作,但行为并非我所期望的,我一次只能选择一个无线电:

<ion-list class="weightunitradios">
  <ion-item>
    <ion-label>kg</ion-label>
    <ion-checkbox 
      mode="ios" 
      value="kg" 
      [(ngModel)]="data.weightunit" 
      ngTrueValue="'kg'" 
      ngFalseValue="'lbs'" 
      (ionChange)="saveWeightUnit(); changeMinMax(); convertWeightInput(); saveUserWeight();">
    </ion-checkbox>
  </ion-item>
  <ion-item>
    <ion-label>lbs</ion-label>
    <ion-checkbox 
      mode="ios" 
      value="lbs" 
      [(ngModel)]="data.weightunit" 
      (ionChange)="saveWeightUnit(); changeMinMax(); convertWeightInput(); saveUserWeight();">
    </ion-checkbox>
  </ion-item>
</ion-list>

0 个答案:

没有答案