Answer the question
In order to leave comments, you need to log in
How to make a for loop in angular?
How to do it without pain in the ass? I didn't see anything even remotely resembling a simple good old for in the documentation.
As I understand it, this is generally done through ng-repeat, but how ??
Somewhere I dug up this example:
<div ng-repeat="i in [0, 1, 2, 3, 4, 5, 6, 7]">
<div>{{i+1}}</div>
</div>
<div ng-repeat="i < 10">
<div>{{i+1}}</div>
</div>
Answer the question
In order to leave comments, you need to log in
Angular Light has a generator filter: al-repeat="_ in 5 | generator"
example , you can do the same in Angular.js.
Read about the meanings of the terms "imperative" and "declarative", drink Novopassit.
even remotely resembling a simple good old for I did not see in it.
well, you probably have data stored somewhere that you want to display -> usually in an array, and specify this array.
for example -> you can, if you wish, write your own (i + 1) to JS in the controller using a FOR loop, for example, saving the result in an array, and display this array through ng-repeat.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question