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.

bug: Can not selet ion-select when FormControl setValue or Show blank but actually selected

See original GitHub issue

Bug Report

Can not select ion-select when FormControl setValue . Actually it’s selected but on display is blank. It’s will be not blank if we give setTimeOut on it like this.

Blank on ion-select

this.myForm.controls.City.setValue(this.city_data[i].id);

Not Blank on ion select

setTimeout( () => {
   this.myForm.controls.City.setValue(this.city_data[i].id);
});

This only happen on data ion-select who data get from server using for. Data item who already write on html will running good when using setValue. Example

<ion-select (ngModelChange)="getStates($event)" formControlName="Country" [class.invalid]="!myForm.controls['Country'].valid && (myForm.controls['Country'].dirty || submitAttempt)">
    <ion-select-option value="{{dm1.id}}" *ngFor="let dm1 of country_data">{{dm1.name}}</ion-select-option>
</ion-select>

Ionic version: [x] 4.9.1

Angular version: [x] 8.2.6

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
3alamprocommented, Oct 5, 2019

I’m having similar issue ion-select where options come from server request don’t show selected value but when I click on it it update and show the correct selected value

<ion-select [(ngModel)]="filters.category" placeholder="{{ 'FILTER.all_placeholder' | translate }}">
  <ion-select-option value="{{ category.id }}" *ngFor="let category of categories?.data">
    {{ category.name }}
  </ion-select-option>
</ion-select>
0reactions
ionitron-bot[bot]commented, Mar 20, 2022

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

bug: Can not selet ion-select when FormControl setValue or ...
Can not select ion-select when FormControl setValue . Actually it's selected but on display is blank. It's will be not blank if we...
Read more >
Cant set value to select in Reactive Form - Stack Overflow
Actually setValue and patchValue are seems working here. We check that with below approach.. this.tourPageForm.get('accomadation').
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >
A thorough exploration of Angular Forms - InDepth.Dev
A FormControl can be considered standalone if it does not belong to an AbstractControl tree. As a result, it will be completely independent,...
Read more >
ngOptions - AngularJS: API
When an item in the <select> menu is selected, the array element or object property represented by the selected option will be bound...
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