0

html

<select ng-model="selectLocation" ng-options="key for key in careerlist.location | orderBy: 'key'">

js (in careerlist controller)

location = ["US-CA-San Clemente", "US- UT- Draper", "US-TX-Dallas", "US-LA-New Orleans", "US-WI-Oshkosh", "US-SC-Charleston", "US-UT-Provo", "US-TX-Fort Worth"]

The select option is populated and functions as intended when making a choice, but it doesn't sort it by alphabetical order.

  • order by would not work on key, you can pass this array to some custom filter which will return an array of object like `[{id: 1, value: "US-CA-San Clement"}, ....]` or I'd recommend you to go through [this answer](http://stackoverflow.com/a/26478321/2435473) – Pankaj Parkar Sep 02 '16 at 18:38

1 Answers1

0

This seems to be a duplicate of this question. Never the less, if you don't want to read that link, can you tell me if this work?

  ng-options="key for key in careerlist.location | orderBy:'toString()' "

Using toStrig works because you are just using a list of strings.

Community
  • 1
  • 1
defaultcheckbox
  • 739
  • 2
  • 5
  • 16