Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70747

Ion-option pre-selection not working

$
0
0

@charlestsmith wrote:

Hello All,
I’m using this example from ionicframework docs:
Im having a for loop for ion options and which should be preselected when the page loads, the preselection is not working. Please help!

I’m using this code in my html:

Hair Color
<ion-select [(ngModel)]=“hairColor” okText=“Okay” cancelText=“Dismiss”>
<ion-option *ngFor=“let o of hairColorData” [value]=“o”>{{o.text}}

and this in my ts file:

this.hairColorData = [
  { text: 'Brown', value: 'brown' },
  { text: 'Blonde', value: 'blonde' },
  { text: 'Black', value: 'black' },
  { text: 'Red', value: 'red' }
];

// Pre-selected object with different object reference
this.hairColor = { text: 'Brown', value: 'brown' };

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70747

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>