UR13X UR13X - 1 year ago 65
AngularJS Question

Iteration ng-repeat only X times in AngularJs

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


<div ng-repeat="4">Text</div>

I want to iterate with ng-repeat 4 times but how can I do it?

mpm mpm
Answer Source

in the html :

<div ng-repeat="t in getTimes(4)">text</div>

and in the controller :

     return new Array(n);



with angularjs > 1.2.x

<div ng-repeat="t in getTimes(4) track by $index">TEXT</div>