Timeline for AngularJS select: remove empty option and use data objects not arrays
Current License: CC BY-SA 3.0
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 23, 2017 at 12:08 | history | edited | URL Rewriter Bot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
| Dec 7, 2016 at 5:18 | answer | added | Naveen Kumar | timeline score: 0 | |
| May 20, 2015 at 11:08 | answer | added | arturmoroz | timeline score: 1 | |
| Sep 2, 2014 at 18:43 | audit | Suggested edits | |||
| Sep 2, 2014 at 19:05 | |||||
| Aug 27, 2014 at 21:41 | answer | added | code-sushi | timeline score: 1 | |
| Aug 27, 2014 at 18:28 | history | edited | code-sushi | CC BY-SA 3.0 |
edited title
|
| Aug 27, 2014 at 18:27 | vote | accept | code-sushi | ||
| Aug 26, 2014 at 7:06 | answer | added | Yoshi | timeline score: 10 | |
| Aug 26, 2014 at 6:55 | comment | added | Yoshi |
I see, no you'll always need two seperate models. One which acts as the list of options (this should probably always be an array of objects) and one to store the selected value (this will then differ in regards to how you set up the ngOptions directive).
|
|
| Aug 25, 2014 at 22:08 | comment | added | code-sushi |
My main concern is what goes in $scope.typeOptions (using the example from the other thread above) INSTEAD OF an array, to get foo.name and foo.bar_id key-value pairs from the data object foo. I have tried putting <select ng-model='fooOptions' ng-options='foo.name as foo.bar_id for foo in fooOptions'></select> but it does not work -- nothing shows up. When I use those as an ng-repeat in the option tag it works (foo.name and foo.bar_id) so the problem isn't with the object properties themselves.
|
|
| Aug 25, 2014 at 22:04 | comment | added | code-sushi | That's fine; I don't have to have "foo.bar_id" as the option value; I just have to have it available so when the user selects an option it is inserted into a corresponding url parameter to update the display. | |
| Aug 25, 2014 at 21:54 | comment | added | Yoshi |
With ngOptions you can't force angular to use your model-data as the actual option-value in the view. Angular handles this in it's own way. It only assures that your scope-model will be set to the correct value on change. If that's not what you want, than you'll have to write your own directive, probably using ngRepeat.
|
|
| Aug 25, 2014 at 21:50 | history | edited | code-sushi |
fixing automistake's auto-mistakes.
|
|
| Aug 25, 2014 at 21:45 | history | edited | code-sushi | CC BY-SA 3.0 |
fixing automistake's auto-mistakes.
|
| Aug 25, 2014 at 21:36 | history | asked | code-sushi | CC BY-SA 3.0 |