I have the following scope in controller:
for(x = 1; x <= 15; x++)
{
x = parseInt(x);
Scope.numArr[x] = x;
}
And in the view, I have the following dropdown box using above Scope "numArr",
<select data-ng-model="printValue" ng-options="v for (k,v) in numArr|
orderBy:'number()': reverse=false">
<option value="">Print options</option>
</select>
I am hitting my head against the wall for not able to sort this simple array. As mentioned in Angularjs doc, it's integer array and not string type. What is the simplest Angular expression to show the values in natural order like 1,2,3,4,5...15.
Currently, Angularjs automatically sorts and shows the dropdown box as 1, 11,12... 15, 2,3..etc.
In PHP or Python, if I utilize the above array, I will have the dropdown in the same order I specified in the array and no headache. Here in AnguarJs, things are bizarre. This statement is just to make it clear that things should be as simple as possible which is what programmers like.
I strongly believe AngularJS team has over complicated this simple diplay of array values into an automatically natural-sorted list in dropdown box. It would be great if the team keeps things as simple as possible.
Any help is greatly appreciated.