question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ion-select always returns string even when value is a number..

See original GitHub issue

Ionic version: (check one with “x”) [ ] 1.x (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1) [ ] 2.x [x] 3.x

I’m submitting a … (check one with “x”) [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

I have a select with an object containing an id and a name. The id is a number and the name is a string. The option value is the id and the display value the name. Setting the select model to an existing id which is a number works and the correct preselected name is displayed. However, chosing a different option rwill return the id of the newly select object but not as a number. Instead it will be a string. I manually need to convert it back…

Expected behavior:

The selected value (id) should be returned as a number when it is a number.

Steps to reproduce:

Create select with multiple options being a number. Select a different option will return it as a string…

Related code:

insert any relevant code here

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

global packages:

    @ionic/cli-plugin-proxy : 1.3.1
    @ionic/cli-utils        : 1.4.0
    Cordova CLI             : 6.5.0
    Ionic CLI               : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 5.2.1 browser 4.1.0 ios 4.2.0 windows 4.4.3
    Ionic Framework                 : ionic-angular 3.2.1

System:

    Node       : v6.10.0
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 4.6.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
AmitMYcommented, Jun 30, 2017

You probably should bind as [value] and not value if that is what you are doing.

0reactions
ionitron-bot[bot]commented, Sep 1, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is the default value of my ion-select not being ...
Vanilla dom properties are always strings and won't match the numeric drive_option . Try: <ion-select-option [value]="0.5">{{ ...
Read more >
Set initial value on ion-select when ngModel is string but ion ...
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, ...
Read more >
Advanced Forms & Validation in Ionic & Angular
A FormControl is tied to an input field, it has a value (i.e. the value ... be an empty string) and is the...
Read more >
Select documentation for Ionic | Mobiscroll
The value can be any kind of object (string, number, object, etc. ... when there are only a few number of options that...
Read more >
How to Build Your First Ionic 4 App with API Calls
We can always change this file and even use a tool like the Ionic ... to return only the results that we need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found