Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
196
rated 0 times [  198] [ 2]  / answers: 1 / hits: 27782  / 9 Years ago, wed, june 3, 2015, 12:00:00

There is such array:



month: Array[13]0: M1: January2: February3: March4: April5: May6: June7: July8: August9: September10: October11: November12: December


I do:



ng-options=key as value for (key, value) in data.month | orderBy:key


But I get unsorted select list.


More From » angularjs

 Answers
43

In order to use tracking with filters use track by.



Markup



ng-options=key as value for (key, value) in data.month | orderBy:'key' track by key


Update



This orderBy will never work because you are having literal array. You need to convert this array to JSON like object which would structured like [{id: 0, value: M}, {id: 1, value: January},......]



HTML



ng-options=item.id as item.value for items in data.month | orderBy:'id'


Demo Plunkr


[#66350] Monday, June 1, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kaitlynnb

Total Points: 402
Total Questions: 96
Total Answers: 109

Location: Trinidad and Tobago
Member since Fri, May 8, 2020
4 Years ago
kaitlynnb questions
;