theintellects theintellects - 4 months ago 16
AngularJS Question

Offset index by 1 in ng-options

I have a selection dropdown populated by an object like this:

<select class="form-control" ng-model="nonexistantmodel" ng-options="idx as idx+1 + order for (idx, order) in amazon.orders">

I'm trying to get the array indices to show up starting from 1. (0,1,2,3 become 1,2,3,4)

But of course
only ends up joining the string and it ends up like
01, 11, 21, 31

I've also tried applying the
filter but to no avail:

(idx+1 | number: 0)
(idx | number: 0) + 1
(idx | number: 0) + (1 | number: 0)

but they all seem to just join strings with the same result.

Is there any way to accomplish this?


Simply change idx+1 with idx*1+1 or idx/1+1 or idx-0+1.

See a live example.