Iteration ng-repeat only X times in AngularJs

前端 未结 7 1970
悲哀的现实
悲哀的现实 2020-11-28 04:08

How can I use ng-repeat like for in Javascript?

example:

Text

I want to iterate wit

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 04:38

    To repeat 7 times, try to use a an array with length=7, then track it by $index:

    
    

    b=[] create an empty Array «b»,
    .length=7 set it's size to «7»,
    &&b let the new Array «b» be available to ng-repeat,
    track by $index where «$index» is the position of iteration.
    ng-bind="$index + 1" display starting at 1.

    To repeat X times:
    just replace 7 by X.

提交回复
热议问题