Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Select don't show the selected option with ngOptions label equals the $viewValue #11170

Closed
felixcoto opened this issue Feb 24, 2015 · 7 comments

Comments

@felixcoto
Copy link

Go to this JSFiddle:
http://jsfiddle.net/felixcoto/v450hf7o/

  1. Push in the button "Load Options"
  2. The first select doesn't show the correct option

This issue is tested in Angular 1.3.13

felixcoto added a commit to felixcoto/angular.js that referenced this issue Feb 24, 2015
Fix selectController when using ngOptions and the label equals the $viewValue of the ngModel.
Otherwise, when the options are loaded, selectController set the value of the select to a
non existing value

Fixes angular#11170
felixcoto added a commit to felixcoto/angular.js that referenced this issue Feb 24, 2015
Fix selectController when using ngOptions and the label equals the $viewValue of the ngModel.
Otherwise, when the options are loaded, selectController set the value of the select to a
non existing value

Fixes angular#11170
felixcoto added a commit to felixcoto/angular.js that referenced this issue Feb 24, 2015
Fix selectController when using ngOptions and the label equals the $viewValue of the ngModel.
Otherwise, when the options are loaded, selectController set the value of the select to a
non existing value

Fixes angular#11170
felixcoto added a commit to felixcoto/angular.js that referenced this issue Feb 25, 2015
Fix selectController when using ngOptions and the label equals the $viewValue of the ngModel.
Otherwise, when the options are loaded, selectController set the value of the select to a
non existing value

Fixes angular#11170
@littleMing
Copy link

The value of two select is not the same.You should write the html like this:
<select name="errorSelect" ng-model="testSelectCtrl.value" ng-options="option.name for option in testSelectCtrl.optionList track by option.name"></select>

@Narretz
Copy link
Contributor

Narretz commented Mar 26, 2015

Interesting. I see the bug in Chrome, but not in Firefox.It also works in 14.0 snapshot

@petebacondarwin
Copy link
Contributor

I think this is one of the reasons that I completely rewrote the ngOptions directive in 1.4.

@petebacondarwin
Copy link
Contributor

This is fixed n 1.4.x - see http://jsfiddle.net/jdt6s5sm/
It is going to be a right pain to fix properly in 1.3.x, which is why we did a complete rewrite of the directive for 1.4.0. @felixcoto could you consider migrating to 1.4? It is in release candidate and will be fully released in just a week or so.

@cyl3392207
Copy link

I think I met the same issue . Going to try the 1.4 version. Is there a workaround for a fix in 1.3.X?

This is a common scenario when I need to select the string value of a list of options instead of getting the Id. So typically I need to use " item.Name as Item.Name for item in items".

@cyl3392207
Copy link

OK. I found a ugly workaround:). " item.Name as Item.Name+' ' for item in items". In this way the select and label are not identical. God, this took me a few hours to find out it is a bug....hoho

@Narretz
Copy link
Contributor

Narretz commented Sep 13, 2015

We've decided not to fix this issue. See #11835 (comment) for more info

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants