1

I'm trying to create a loop that prints HTML a certain number of times. I know the number because its in the scope. Must I loop through the numbers and push them into an array beforehand in order to use ng-repeat which seems to only accept collections?

neptunian
  • 410
  • 4
  • 17
  • You want to avoid the loop or the array creation ?? – Manish Kr. Shukla Aug 14 '14 at 05:10
  • I am trying to avoid having to create an extra loop by building an array for ng-repeat to loop through. – neptunian Aug 14 '14 at 05:14
  • This might help: http://stackoverflow.com/questions/11873570/angularjs-for-loop-with-numbers-ranges – runTarm Aug 14 '14 at 05:18
  • ngRepeat is basically a directive. If you tend to use your functionality many times in the project, you may consider creating the directive with intended functionality as yours. – skjoshi Aug 14 '14 at 05:22
  • Possible duplicate of [Way to ng-repeat defined number of times instead of repeating over array?](http://stackoverflow.com/questions/16824853/way-to-ng-repeat-defined-number-of-times-instead-of-repeating-over-array) – stamat Mar 21 '16 at 14:04

0 Answers0