AngularJS, order text selection with a non-array model?

Viewed 45

I am using the ng-options="ref as display for (ref, display) in syntax to display a non-array object as a dropdown, but am having trouble ordering the dropdown values.

How should I use the orderBy filter to sort this dropdown by display value?

    <div ng-controller="MyCtrl">
      <select name="category" type="text" ng-model="categories " ng-options="ref as display 
for (ref, display) in categories | orderBy:'display'" >

    </div>

    var myApp = angular.module('myApp',[]);
    function MyCtrl($scope) {
      $scope.categories = {
          cat2: "Category 2",
          default: "anone",
          zone: "zone",
        };
    }

http://jsfiddle.net/ADukg/13412/

1 Answers
Related