如何解决使用 FormArrayControl Angular 从动态表访问数据
我有一个由列表创建的动态表,用户单击复选框后,每一行都有一个复选框 我希望能够访问该复选框列的所有列值,有人告诉我我需要一个 FormArray要做到这一点,但我不知道如何做到
这是我的桌子:
<div class="table-responsive angular-bootstrap-table">
<table class="table table-head-custom table-vertical-center overflow-hidden">
<thead>
<th>
#
</th>
<th>
Desc
</th>
<th>
Cap
</th>
<th>
$$$
</th>
</thead>
<ng-container *ngFor="let habDispo of mySet ">
<ng-container formArrayName="info" *ngFor="let tipe of cuartos let i=index">
<tbody *ngIf="tipe.Number == habDispo" [formGroup]="i">
<tr>
<td formControlName="Checked"><mat-checkbox (checked)="preAsignar(tipocuarto.Numero)"></mat-checkbox> {{ tipocuarto.Numero }}</td>
<td formControlName="cuartoDescripcion">{{ tipocuarto.Descripcion}}</td>
<td formControlName="cuartoPersonas">{{ tipocuarto.Personas }} Adultos</td>
<td formControlName="cuartoTarifa">{{ tipocuarto.Tarifa }}.00</td>
</tr>
</tbody>
</ng-container>
</ng-container>
</table>
</div>
{{this.formGroup.value | json}} //which returns every forvalue in my form but the formarray comes empty without any controls or values
在我的 Ts 文件中
this.formGroup = this.fb.group({
infoCuartos:this.fb.array([
])
});
如何在用户选中复选框后访问我的表格数据?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。