angular - 使用 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([
])
});
用户选择复选框后如何访问我的表格数据?
解决方案
推荐阅读
- javascript - Jekyll 没有为图像加载 Javascript
- facebook - FB Graph API - 不显示成功的预定发布
- python - 导入后python模块子文件夹不可用
- javascript - Vue.js $refs 未定义
- android - 我如何使用 FragmentStatePagerAdapter 有什么问题?
- android - “TextView”在三星 Galaxy Tab 上被裁剪
- javascript - D3 漏斗图中的工具提示位置无法正常工作
- java - 在 Eclipse Photon 中使用 Maven 构建 - 如何获得控制台颜色?
- docker - Traefik 与 docker-compose、LetsEncrypt 和多个域
- javascript - 联系表格 7 - 提交表格后添加延迟重定向