I have a simple select drop down list that is bound by key/value
pairs. However, the drop down list does not show option items in the
order I want. I try to use "orderBy" filter, but I do not know how to do it. Please help. Thank you in advance.
I want it to show as follows:
10
20
30
50
100
However, it shows those option items as (100 is in the wrong place) before I try to use the "orderBy" filter.
10
100
20
30
50
The following is my JS codes for my controller:
var myApp = angular.module('ListLogsModule', []);
myApp.controller('ListLogsCtrl', function ($scope) {
// the data is made in order I want.
$scope.pageSizeOptions= {"10": "10", "20" : "20", "30" : "30", "50" : "50", "100" : "100"};
// default selected item
$scope.SelectedPageSize = "10";
}
And HTML as follows. How can I specify the "orderBy" expression?
<div ng-app="ListLogsModule" ng-controller="ListLogsCtrl">
<span>Page Size:</span>
<span>
<select ng-model="SelectedPageSize" ng-options="k as v for (k,v) in pageSizeOptions | orderBy:?" >
</select>
</span>
</div>
$scope.pageSizeOptions= {"1001": "10", "1002" : "20", "1003" : "30", "1004" : "50", "1005" : "100"};
2. v in bold red
HTML:
<select ng-model="SelectedPageSize" ng-options="v as v for (k,v) in pageSizeOptions | orderBy:?" >
</select>