Dynamically create array of HTML elements with typescript in Angular 2/4

Viewed 4029

I want to dynamically add divs using a loop with typescript in angular. I want to reproduce the following pseudocode in my .ts component file:

i: number = 4;
arrayofHTMLelements: html elements = [];

for i in range (1, i):
    create div at index i

I'm assuming I could then slide the array of HTML elements into the .html component file using:

<li *ngFor="let arrayofHTMLelement of arrayofHTMLelements; let i = index">{{i + 1}}: {{arrayofHTMLelements}}</li>
1 Answers
Related