Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs, how use ng-repeat range 5 to 10

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>
like image 223
a.fauzi Avatar asked Feb 06 '14 10:02

a.fauzi


People also ask

What is the use of NG-repeat in AngularJS?

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.

How do you pass an index in NG-repeat?

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.

What can I use instead of NG-repeat?

You can consider using transclusion inside a custom directive, to achieve the behavior you are looking for without using ng-repeat.


1 Answers

What about

<select>
  <option ng-repeat="n in [] | range:6" value="{{$index+5}}">{{$index+5}}</option>
</select>
like image 93
Alexander Nenkov Avatar answered Oct 28 '22 07:10

Alexander Nenkov