Home > Software engineering >  ion-radio default checked *ngfor
ion-radio default checked *ngfor

Time:03-04

I'm new to ionic-framework. My task is next, I want, When the component is opened, the radio button should be checked default. I want one to be checked.Thanks in advance

enter image description here

Screen image

file typescript

tools.component.html

CodePudding user response:

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

  • Related