18910140161

HTML-角度材质表中未指定名称属性的表单控件没有值访问器-堆栈溢出

顺晟科技

2022-10-18 13:04:37

171

我有一张有角的材料表。我想根据一个可以改变的值来显示它。如果值为true,则应显示,否则不显示。当值更改为true时,我得到以下错误:错误:具有未指定名称属性的表单控件没有值访问器。我想我没有正确地绑定它,但我没有看到错误。HTML:

<div class="mat-elevation-z8 layout-container" [(ngModel)]="tableIsVisible" *ngIf="tableIsVisible">
  <table mat-table [dataSource]="dataSourceTable">
    <ng-container matColumnDef="index">
      <th mat-header-cell *matHeaderCellDef [attr.rowspan]="2">No.</th>
      <td mat-cell *matCellDef="let element; let i = index">{{ i + 1 }}</td>
    </ng-container>

    <tr mat-header-row *matHeaderRowDef="header"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns; let i = index"></tr>
  </table>

  <mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons aria-label="Select page of periodic elements"> </mat-paginator>
</div>

TS:

tableIsVisible: boolean;
//tableIsVisible value is changing based of a function. 

顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航