Skip to content

bug: ion-select does not show selected if number #5495

@jasonwaters

Description

@jasonwaters

Type: bug

Ionic Version: 2.x

Platform: all

If you have the following code:

<ion-item>
  <ion-label>Watering Mode</ion-label>
  <ion-select [(ngModel)]="zone.kind">
    <ion-option *ngFor="#key of modeKeys">{{key}}</ion-option>
  </ion-select>
</ion-item>

and

  this.zone = {
    kind: 'key2'
  }
  this.modeKeys = [
    'key1',
    'key2',
    'key3',
    'key4',
  ]

A select component is displayed with 'key2' shown as selected.

But if you change the data to this:

  this.zone = {
    kind: 2
  }
  this.modeKeys = [
    1,
    2,
    3,
    4,
  ]

It does not work. Seems the component prefer strings.

https://forum.ionicframework.com/t/ion-select-with-dynamic-options/43720/7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions