Using Angular 2, I want to duplicate a line in a template multiple times. Iterating over an object is easy, *ngFor="let object of objects"
. However, I
You can instantiate an empty array with a given number of entries if you pass an int
to the Array
constructor and then iterate over it via ngFor
.
In your component code :
export class ForLoop {
fakeArray = new Array(12);
}
In your template :
- Something {{ index }}
The index properties give you the iteration number.
Live version