angular - 如何在 Angular 6 中显示表单控件值?
问题描述
我试图在跨度标签中显示表单控件,而不是在输入标签中。所以我尝试了下面的
<div formArrayName="genes">
<table>
<thead>
<tr>
<th>Position</th>
</tr>
</thead>
<tbody *ngFor="let gene of genesControls.controls; let i = index" [formGroupName]="i">
<td>
<span>
{{gene.position}} //not working
{{position}} //not working
{{gene.position.value}} //not working
{{position.value}} //not working
</span>
<!--input formControlName="position" id="pos"> This is working-->
</td>
</tbody>
</table>
</div>
当我在输入标签内尝试时,它正在工作,但跨度或其他标签不起作用,我不知道这里发生了什么,根据文档,我也尝试了值,但出了点问题。我该如何解决这个问题?
解决方案
如果要访问它们的值,可以通过以下方式访问:
<tbody *ngFor="let gene of genesControls.controls; let i = index" [formGroupName]="i">
<td>
<span>{{gene.value.position}}</span>
<!--input formControlName="position" id="pos"> This is working-->
</td>
</tbody>
推荐阅读
- javascript - 了解从 lon., lat. 的无证转换。地球表面坐标到图像的 x, y 坐标
- javascript - 在具有许多子组件的组件上改进 updateState - Reactjs
- python - 在 python 中的 dict 中创建 k/v 对的性能
- sed - 如何修改sed范围内的倒数第二行
- javascript - 自定义 JS-DOS DosBox.conf 实现问题
- flutter - Flutter:使图像更小
- python - 使用 AWS Lambda (Python) 从 multipart/form-data 保存图像
- c# - 转换 IQueryable
到 IQueryable 删除空值后 - unix - rsync 文件在文件夹名称中带有空格的问题
- javascript - 如何使用 onclick 事件更新从 SVG 元素读取的工具提示的值?