@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