Developer18
Developer18

Reputation: 21

How to display default value in ion-select from one of the value obtained from locaStorage?

<ion-select (ionChange)="onCountryChange($event)" [value]="country" formControlName ="country" name="country">
<ion-select-option [value]="country.name" *ngFor="let country of countryList">
{{country.name}} 
</ion-select-option>
</ion-select>

I need to set the default value from one the value obtained from local storage when the page loads

Upvotes: 1

Views: 85

Answers (1)

Swati
Swati

Reputation: 11

For HTML

<ion-select (ionChange)="onCountryChange($event)" [value]="selectedType" formControlName ="country" name="country">
<ion-select-option [value]="country.name" *ngFor="let country of countryList">
{{country.name}} 
</ion-select-option>
</ion-select>

For TypeScript

 this.selectedType = countryList.find(c => c.value == 'condition');

Upvotes: 1

Related Questions