# Ionic 4 not showing selected value in ion-select

**URL:** <https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732>\
**Category:** Ionic Framework\
**Created:** [February 21, 2020, 10:13am UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732 "2020-02-21T10:13:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeanCMSSystems](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DeanCMSSystems](https://forum.ionicframework.com/u/DeanCMSSystems)\
**Post date:** [February 21, 2020, 10:13am UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732/1 "2020-02-21T10:13:35Z")

</div>

**Problem:**  
I have an ion-select and in the controller when the user does something, I populate the ion-select with 1 value and make that value the selected value. The ion-select does not show that the value has been selected, but the [(ngModel)] is the correct value. When I open the ion-select it shows the value in the list and it is selected, when selecting the value in the list again it goes over the ion-select label.

**Screenshots:**

1. The **Make** has value of **CHEVROLET** but it is not selected by ion-select  

2. When tapping on ion-select, it shows the **CHEVROLET** as selected and **CHEVROLET** goes over the **Make** label  

HTML:

```auto
<ion-item>
   <ion-label position="floating">
      <span class="required">* </span>Make
   </ion-label>
   <ion-select [interfaceOptions]="global.compactAlertOptions" id="make" [(ngModel)]="global.valuation.vehicle.make" name="make" #makeRef="ngModel" required>
      <ion-select-option *ngFor="let make of makes">{{make}}</ion-select-option>
   </ion-select>
</ion-item>
<ion-label *ngIf="makeRef.touched && makeRef.invalid && makeRef.errors.required" class="error">Make is required</ion-label>

```

Controller:

1. Modal Controller (the **Make** gets set in a popup modal):

```auto
      this.global.valuation.vehicle.make = this.vehicleDetails.VehicleMake;

```

1. Populate the ion-select in parent controller:

```auto
      this.makes = [this.global.valuation.vehicle.make];

```

---

<div class="post-metadata">

**Author:** ![PratikVaity](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@PratikVaity](https://forum.ionicframework.com/u/PratikVaity)\
**Post date:** [February 21, 2020, 12:31pm UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732/2 "2020-02-21T12:31:14Z")

</div>

you can use placeholder instead of label.

---

<div class="post-metadata">

**Author:** ![DeanCMSSystems](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DeanCMSSystems](https://forum.ionicframework.com/u/DeanCMSSystems)\
**Post date:** [February 21, 2020, 12:47pm UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732/3 "2020-02-21T12:47:46Z")

</div>

Thanks for the reply, but will a placeholder have the floating effect as a label and I am also using a CSS class inside the label, not sure if it’s possible with a placeholder

---

<div class="post-metadata">

**Author:** ![PratikVaity](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@PratikVaity](https://forum.ionicframework.com/u/PratikVaity)\
**Post date:** [February 21, 2020, 1:26pm UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732/4 "2020-02-21T13:26:48Z")

</div>

Yea placeholder will not have that effect…

---

<div class="post-metadata">

**Author:** ![webteambel](https://avatars.discourse-cdn.com/v4/letter/w/f6c823/32.png) [@webteambel](https://forum.ionicframework.com/u/webteambel)\
**Post date:** [February 21, 2020, 1:29pm UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732/5 "2020-02-21T13:29:45Z")

</div>

> [@DeanCMSSystems](#):
>
> en the ion-select it shows the value in the list and it i

Hi,  
I had the same problem, add a timeout and it will work

```auto
setTimeout(() => {
     // your code
    }, 100);

```

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [February 21, 2020, 7:41pm UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732/6 "2020-02-21T19:41:25Z")

</div>

Please don’t take the advice in the post above this one.

`setTimeout`, especially with magic numbers, is something that should be avoided as much as humanly possible. It deliberately obscures either a race condition or a problem with change detection that should rather be addressed directly.

To OP: aside from the scoping concerns of what appears to be going on with `global` here (which I think are legitimate), I worry about change detection and deep object inspection here. Can you try an experiment and do whatever is necessary to eliminate all dots from the `[(ngModel)]` binding and see if your problem still persists?

---

<div class="post-metadata">

**Author:** ![DeanCMSSystems](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DeanCMSSystems](https://forum.ionicframework.com/u/DeanCMSSystems)\
**Post date:** [February 25, 2020, 2:13pm UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732/8 "2020-02-25T14:13:43Z")

</div>

Thanks for the reply.

I did a test where instead of `this.global.valuation.vehicle.make` I use `this.make` and it worked fine.  
So is there a restriction on how many child properties the model variable must have? Because the `global` variable I use on 3 pages (to pass data between these 3 components).

I added an on change event on the `this.make` where I stamp the `global` variable with `this.make` and this seems to work fine, but sort of a “hackey way” to make it work

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [February 25, 2020, 7:40pm UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732/9 "2020-02-25T19:40:20Z")

</div>

> [@DeanCMSSystems](#):
>
> is there a restriction on how many child properties the model variable must have?

I would phrase it more as “how many levels deep of inspection you can reasonably expect Angular’s change detection to notice stuff at”, and it’s possible that things have gotten better on this front since I repeatedly stepped on this rake, but my rule is “1”. I would not bind anything deeper than `foo.bar`.

> [@DeanCMSSystems](#):
>
> the `global` variable I use on 3 pages (to pass data between these 3 components).

I figured as much. Perhaps while we’re here I could impose on you to check out [this post](https://forum.ionicframework.com/t/ionic-4-tab-to-page-then-back-to-tab-did-not-trigger-ionviewwillenter-solved/167922/11)? When I was exposing stuff like this as a plain variable, I kept running into the problem of “how do I communicate changes to consumers (pages/components that care)?”. Exposing them as `Observable`s in the service solves that problem, and incidentally should solve this one as well, because your subscription to `global.valuation$` will take care of updating a property in the page controller.

> [@DeanCMSSystems](#):
>
> I added an on change event on the `this.make` where I stamp the `global` variable with `this.make` and this seems to work fine, but sort of a “hackey way” to make it work

…and that refactoring should obviate the need for this as well.

---

<div class="post-metadata">

**Author:** ![DeanCMSSystems](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@DeanCMSSystems](https://forum.ionicframework.com/u/DeanCMSSystems)\
**Post date:** [February 26, 2020, 7:17am UTC](https://forum.ionicframework.com/t/ionic-4-not-showing-selected-value-in-ion-select/183732/10 "2020-02-26T07:17:50Z")

</div>

> [@rapropos](#):
>
> I figured as much. Perhaps while we’re here I could impose on you to check out [this post](https://forum.ionicframework.com/t/ionic-4-tab-to-page-then-back-to-tab-did-not-trigger-ionviewwillenter-solved/167922/11)?

Awesome thanks. Will definitely make use of this. Nice way to make variable available across components. Guess I learn something new every day 💪
