Programmatically Checking Ion Radio from TypeScript

I have a fairly simple question, but I cannot find an answer. I have this code:

<ion-list radio-group [(ngModel)]="profile_activities" name="activities">
    <ion-item>
        <ion-label>Option 1</ion-label>
        <ion-radio  (ionSelect)='selectedActivity($event);' value="0"></ion-radio>
    </ion-item>

    <ion-item>
        <ion-label>Option 2</ion-label>
        <ion-radio (ionSelect)='selectedActivity($event);' value="1"></ion-radio>
    </ion-item>

    <ion-item>
        <ion-label>Option 3</ion-label>
        <ion-radio (ionSelect)='selectedActivity($event);' value="2"></ion-radio>
    </ion-item>
</ion-list>

      

... and I would just like to pre-validate the value from typescript based on the information I am getting from my database. How can I check ionic radio from Typescript?

Thank!

+3


source to share


1 answer


Ok, I managed to find the answer. In TypeScript, I just need to enter a default value for the radio to be checked like this:

this.profile_activities = "1";

      



... for example, in the function ionViewWillEnter()

and the radio is checked with value="1"

!

+2


source







All Articles