YStaum
YStaum

Reputation: 69

Set ng-repeat to a variable

I have a mutable variable, and I need to repeat an element to the value of this variable. Is there a way to set ng-repeat to a set value (not objects or arrays).

(My actual code is much more complicated. Includes get the value from a js object via $http)

Upvotes: 0

Views: 31

Answers (1)

Faustyn Piechowiak
Faustyn Piechowiak

Reputation: 228

If I understand you correctly - the easiest way of achieve this would be to construct array based on variable and iterate over it.

ng-repeat="x in [].constructor(number) track by $index"

where number is your variable.

Upvotes: 2

Related Questions