I am working on a issue, where I need to generate dynamic rows of a table based on the input given by user through textbox.
My .ts code:
start(val){
this.printVal=val;
console.log('Value of start is',this.printVal);
return new Array(val);
}
.html code:
<div class="container col-lg-12">
<input type="number" #data>
<button (click)="start(data.value)">Start</button>
<br><br>
<table>
<ng-container >
<tr *ngFor="let item of [].constructor(printVal); let i = index"> //If instead of printVal, I give a number then it prints the desired output
<td>{{i}}</td>
</tr>
</ng-container>
</table>
</div>
Actually i need to create a table like this
| Input|sec|Multipilcation
|------|---|------------------------------
|10 |1 |10
|10 |2 |20
|10 |3 |30
|10 |4 |40
.
.
.
10 |10 |100
Where 10 is the number provided through input box, after each second a row should get add and it value should get print and third column in multiplication of both and the table row should get continue till the input value provided.
Please, suggest me what I am doing wrong and how can I print dynamic rows based on the input provided.
*ngFor="let item of [].constructor(printVal); let i = index"Why ?