@trfletch wrote:
I have an ion-select setup as follows, the “attribute.value” is a string but the “option.id” on each ion-select-option is an integer, I need to set the initial value of the select based on “attribute.value”. What I have below worked fine on Ionic 3 but on Ionic 4 and Ionic 5 this doesn’t work, I assume because one is a string and one is an integer so it doesn’t think that they match, I believe on Ionic 3 it must have just converted the [value] on an ion-select-option to a string by default.
The “attributes” I am using are dynamic so they can be a string or an integer when they come from the datasource, therefore, I do not have the option of just changing it so that “attribute.value” is instead an integer when it reaches the page.
I effectively need a way of converting the “attribute.value” to an integer within the HTML in [(ngModel])] so that it matches with the correct ion-select-option and sets the correct initial value. How can I do this?
<ion-select [(ngModel)]="attribute.Value" interface="popover"> <ion-select-option *ngFor="let option of attribute.Options" [value]="option.Id">{{option.Name}}</ion-select-option> </ion-select>
Posts: 1
Participants: 1