问题描述
我有一个带有两个输入columnas
和filas
(columns
和rows
)的表单
并通过这两个数据创建一个nxn表,并用表中的随机数据填充它们:
但是由于我是动态添加行和列的,所以我不知道如何为该表中的每个输入创建标识符并将其通过NgForm发送到方法。
<form (ngSubmit)="ejecutarModelos(g.value)" #g="ngForm" *ngIf="mostrarMatriz && datos.manual">
<h4 class="display-6">Matriz Manual:</h4>
<table class="table table-bordered jumbotron">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col" *ngFor="let columna of arrayColumnas">Col. {{columna}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let fila of arrayFilas">
<th>Fila {{fila}}</th>
<td *ngFor="let obj of td.arrayRandom">{{obj[fila]}}</td>
</tr>
</tbody>
</table>
</form>
component.ts
ejecutarRandom(f: NgForm) {
this.resultadoLagrange = f.value.columnas;
let nColumnas = 1 / f.value.columnas;
this.arrayColumnas = [];
this.arrayFilas = [];
for (let index = 1; index <= f.value.filas; index++) {
this.arrayFilas.push(index);
}
for (let index = 1; index <= f.value.columnas; index++) {
this.arrayColumnas.push(index);
let obj = {}
for (let index = 1; index <= this.arrayFilas.length; index++) {
let first = index;
obj[first] = this.getRandom(f.value.rangoMin,f.value.rangoMax);
}
this.td.arrayRandom.push(obj)
}
this.td.arrayLagrnage = [...this.td.arrayRandom]
this.metotodoLagrange(this.td.arrayLagrnage,nColumnas);
this.mostrarMatriz = true;
};
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)