<ion-item>
<ion-label>Gender</ion-label>
<ion-select [(ngModel)]=“gender”>
<ion-option value=“m”>Male</ion-option>
<ion-option value=“f”>Female</ion-option>
</ion-select>
</ion-item>
in ts file i want to set condition if value is male or felmale
if(this.Value = “m” ){
return this.res;
}
else if (this.Value = "f" ){
this.res = ;
}
Use ngModel like
TS:
radio: string = 'option1';
change() {
if (this.radio == "option2"){
console.log("heeeey i'm working");
} else {
console.log("heeeeeey i'm still working");
}
}
HTML:
<ion-select (ionChange)="change()" [(ngModel)]="radio">
<ion-option value="option1">Option 1</ion-option>
<ion-option value="option2">Option 2</ion-option>
<ion-option value="option3">Option 3</ion-option>
<ion-option value="option4">Option 4</ion-option>
</ion-select>
1 Like