Javascript 我试图编辑表格中的单元格,我的表格是nxn矩阵,对角线两侧的值相似
使用角度反应形式,我根据所选复选框的数量生成nxn矩阵表。但是我想编辑两边都有相同值的表格单元格,这可以通过在相反单元格上使用双向绑定来完成。所有对角线值均为1,不可编辑 代码到目前为止Javascript 我试图编辑表格中的单元格,我的表格是nxn矩阵,对角线两侧的值相似,javascript,angular,matrix,angular-reactive-forms,Javascript,Angular,Matrix,Angular Reactive Forms,使用角度反应形式,我根据所选复选框的数量生成nxn矩阵表。但是我想编辑两边都有相同值的表格单元格,这可以通过在相反单元格上使用双向绑定来完成。所有对角线值均为1,不可编辑 代码到目前为止 <div class="form-group"> <table *ngIf="showTable" class="table table-striped table-bordered" style="width:50%;" formControlName
<div class="form-group">
<table *ngIf="showTable" class="table table-striped table-bordered"
style="width:50%;" formControlName="correlations">
<thead>
<tr>
<th *ngFor="let parameter of checked">{{parameter}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let row of correlationValues">
<td contenteditable="true" style="background-
color:#b1dbf9" *ngFor="let col of row">{{col}}</td>
</tr>
</tbody>
</table>
</div>
{{参数}}
{{col}}
列值来自选中的复选框值
创建矩阵的代码
createMatrix(n:number) {
var innerArr;
this.correlationValues = [];
for (var i=0; i<n; i++){
innerArr = [];
for (var j=0; j<n; j++) {
innerArr.push((i+j+1)%2);
}
this.correlationValues.push(innerArr);
}
console.log(this.correlationValues.toString());
return this.correlationValues;
}
createMatrix(n:number){
var innerArr;
this.correlationValues=[];
对于(var i=0;这是解决此类问题的角度方法,请使用jquery