You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Angular Form Array与Angular Material Table报错:找不到id为position的列

Angular Form Array结合Angular Material Table报错:找不到id为"position"的列

我尝试基于Angular Form Array构建Angular Material Table时,遇到如下报错:

Could not find column with id "position".

我查阅了大量关于matColumnDef指令的解决方案,代码中已经包含该指令,且名称与dataSource一致,示例代码如下:

<ng-container matColumnDef="position">
    <th mat-header-cell *matHeaderCellDef> No. </th>
    <td mat-cell *matCellDef="let element" [formControlName]='arrayOfProperties[0]' > {{element.position}} </td>
</ng-container>

我推测问题出在表格的构建方式上,相关代码片段如下:

<div formArrayName="tourTable" *ngFor="let controls of tourTable.controls; let i = index;">
    <div [formGroupName]="i">

内容的提问来源于stack exchange,提问作者paulotarcio

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 15:39:18