AngularJS ngOptions sort array

后端 未结 2 2160
北荒
北荒 2020-12-15 04:58

I have been trying to use ng-options to display an array of fonts in a select sorted alphabetically by the value of the items in the array.

HTML

2条回答
  •  太阳男子
    2020-12-15 05:36

    As the documentation specifies, the string argument is for object properties, not for primitives. I think, as elementary as it sounds, you have to create a function on the scope that simply returns the argument, and pass that to orderBy.

    See jsFiddle!

提交回复
热议问题