I’m having some trouble finding info on this so I’ll try asking here. I hope it’s ok, since it’s not really Ionic 2 related.
I’'m trying to create a simple for-loop like this:
<ion-icon *ngFor="#index of range">
ngFor only seems to work with collections, so in my class, I have to define define “range” like this:
private range:number[] = [1, 2, 3, 4, 5];
This seems iffy to me, and I would much rather have range to be a number constant. Do you guys know if there really is an angular limitation for loops through collections only?
Are you trying to just declare the range and loop with the values in the range? say range(5) should be like ngFor with [1,2,3,4,5] or you don’t care about the values, just care about the number of iterations?
luchillo17, exactly, I don’t care about the values, i just want to print 5 icons like this:
*ngFor="#index of range"
Willb, it’s not a significant problem, I’m learning Angular2 and thought I should ask, since it seems strange to me that I can’t create a simple loop using a set number of iterations without a collection.
Could you please explain _.range(5) a bit?
I’m currently working on a dynamic grid that prints icons on a homepage. Take a peek at my code…perhaps it will help. You have to use the ngFor index to help.
What you would suggest if I want to go through a collection and want to generate, let say, 4 columns per row where each column represent an item (i) from my collection.