I use like this to loop number:
<select>
<option ng-repeat="n in [] | range:10" value="{{$index+1}}">{{$index+1}}</option>
</select>
This works, but how i can get like this with ng-reapet (5 to 10)?
<select>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
AngularJS ng-repeat Directive The ng-repeat directive repeats a set of HTML, a given number of times. The set of HTML will be repeated once per item in a collection. The collection must be an array or an object.
Each ng-repeat creates a child scope with the passed data, and also adds an additional $index variable in that scope. So what you need to do is reach up to the parent scope, and use that $index . Save this answer.
You can consider using transclusion inside a custom directive, to achieve the behavior you are looking for without using ng-repeat.
What about
<select>
<option ng-repeat="n in [] | range:6" value="{{$index+5}}">{{$index+5}}</option>
</select>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With