Ionic 已检查离子无线电默认值 *ngfor

ljsrvy3e  于 2022-12-09  发布在  Ionic
关注(0)|答案(1)|浏览(137)

我是第一次使用ionic-framework。我的任务是下一个,我想,当组件打开时,单选按钮应该默认选中。我想选中一个。提前感谢
在此输入图像描述
Screen image
file typescript
tools.component.html

w1jd8yoj

w1jd8yoj1#

I haven't really grasped the meaning of your component, but I would say that initializing your "radioList" variable to 0 should be sufficient.
Also, it would be better to go by the id of your ColorValueObjInterface. it would give, in your .ts

radioList:number = colorValueObj[0]?.id || 0;

And your .html

...
<ion-radio type="radio" [value]="item.id" name...></ion-radio>
...

And please, use the code sample btn to post your code

相关问题