Sorting dropdown alphabetically in AngularJS

前端 未结 4 1578
情话喂你
情话喂你 2020-12-07 15:19

I\'m populating a dropdown through the use of ng-options which is hooked to a controller that in turn is calling a service. Unfortunately the data coming in is a mess and I

4条回答
  •  青春惊慌失措
    2020-12-07 15:48

    You should be able to use filter: orderBy

    orderBy can accept a third option for the reverse flag.

    
    

    Here item is sorted by 'name' property in a reversed order. The 2nd argument can be any order function, so you can sort in any rule.

    @see http://docs.angularjs.org/api/ng.filter:orderBy

提交回复
热议问题