Hello to all! I'm new to Angular. The goal is to create a table with N - the number of empty rows. Where N is specified in the .component.ts file - numOfRows: number = 5. A label with N empty rows should be output in the .component.html file (there are cells but they are empty, it is done so that the user enters the values ​​there).

enter image description here

    1 answer 1

    You can do something like this:

    Create a method in the ts file (which will return an array with the size numRows ):

    getRows(): Array<string>{ return new Array(this.numOfRows); } 

    Generating a table in a template will look like this:

     <table> <thead> <th>Label1</th> <th>Label2</th> <th>Label3</th> <th>Label4</th> <th>Label5</th> </thead> <tbody> <tr *ngFor="let i of getRows()"> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table>