在离子无线电组内部时选择了多个离子无线电

时间:2019-12-03 16:25:25

标签: angular ionic4

我在ion-radio中有2个ion-radio-group,因此根据doc,应该只选择一个ion-radio,但是我可以同时单击两个...单击一个,无法取消选中单选按钮...

  <div *ngFor="let question of survey; let j = index">
      <h2>{{question.text}}</h2>

      <div [ngSwitch]="question.type">

      <ion-list *ngSwitchCase=types.singleChoice>

        <ion-radio-group>
          <ion-item *ngFor="let item of question.items; let i = index">
           <ion-label>{{item.text}}</ion-label>
            <ion-radio slot="start" value="item.text"></ion-radio>
           </ion-item>
         </ion-radio-group>
      </ion-list>


       <ion-item *ngSwitchCase=types.ratingScale>
         <ion-range min="{{question.min}}" max="{{question.max}}" step="{{question.step}}"  color="secondary" pin="true">
         <ion-label slot="start">{{question.min}}</ion-label>
         <ion-label slot="end">{{question.max}}</ion-label>
         </ion-range>
         </ion-item>
        </div>
     </div>

这是我的.ts文件,其中有我的ngfor绑定的数组:

  types: any = {
    singleChoice: 1,
    ratingScale: 2,
};

  survey = [
          {
          id: 0,
          type: 1,
          text: 'Question 1',
          items: [
            { id: 0, text: 'Oui', checked: false },
            { id: 1, text: 'Non', checked: false }
          ],
          required: true
        },
        {
          id: 1,
          type: 1,
          text: 'Question 2',
          items: [
            { id: 0, text: 'Oui', checked: false },
            { id: 1, text: 'Non', checked: false },
          ],
          required: true
        },
        {
          id: 2,
          type: 2,
          text: 'Question 3',
          min: 0,
          max: 10,
          step: 1,
          required: false
        },
];

0 个答案:

没有答案