如何修复从阵列中选择的离子-放射性基团

时间:2019-07-13 16:42:24

标签: angular typescript ionic-framework

我要自动选中单选按钮,但无法选择

我尝试禁用单选按钮,但此功能正常,但已检查不起作用

在page.html

<div *ngIf="soal?.kind == 2">
      <ion-radio-group [(ngModel)]="jawaban">
        <ion-item *ngFor="let cat of answer">
          <ion-label>{{cat.text}}</ion-label>
          <ion-radio *ngIf="cat?.checked" slot="end" value="{{cat.key}}" checked></ion-radio>
          <ion-radio *ngIf="!cat?.checked" slot="end" value="{{cat.key}}"></ion-radio>
        </ion-item>
      </ion-radio-group>
    </div>

1 个答案:

答案 0 :(得分:0)

.html

<div *ngIf="soal?.kind == 2">
      <ion-radio-group [(ngModel)]="jawaban">
        <ion-item *ngFor="let cat of answer">
          <ion-label>{{cat.text}}</ion-label>
          <ion-radio [attr.checked]="value === 'black' ? 'checked' : null"  slot="end" value="{{cat.key}}" ></ion-radio>
          <ion-radio [attr.checked]="value === 'brown' ? 'checked' : null" slot="end" value="{{cat.key}}"></ion-radio>
        </ion-item>
      </ion-radio-group>
    </div>

.ts

value = 'brown';