Typescript 如何使用表单功能创建物料数据表以保存记录

Typescript 如何使用表单功能创建物料数据表以保存记录,typescript,angular-material2,angular5,Typescript,Angular Material2,Angular5,犯了很多错误 无法读取未定义的属性“toUpperCase” ]*matRowDef=列:displayedColumns> 在表中动态添加行的步骤 <button (click)="addABunch(3)">Add 3</button> 使用is名称和手机号码创建用户 <mat-table #table> <ng-container matColumnDef="Username"> <m

犯了很多错误

无法读取未定义的属性“toUpperCase” ]*matRowDef=列:displayedColumns>

在表中动态添加行的步骤

<button (click)="addABunch(3)">Add 3</button>
使用is名称和手机号码创建用户

<mat-table #table>
            <ng-container matColumnDef="Username">
            <mat-header-cell *matHeaderCellDef>Drug Name</mat-header-cell>
            <mat-cell >
                <mat-form-field class="example-full-width">
                    <input class="form-control" matInput 
                                   formControlName="Name">
                  </mat-form-field>
            </mat-cell>
            </ng-container>
        <ng-container matColumnDef="Mobile">
            <mat-header-cell *matHeaderCellDef>Drug Name</mat-header-cell>
            <mat-cell>
                <mat-form-field class="example-full-width">
                    <input class="form-control" matInput 
                         formControlName="Mobile">
                  </mat-form-field>
            </mat-cell>
            </ng-container>
            <mat-header-row *matHeaderRowDef="displayedColumns">
                        </mat-header-row>
            <mat-row *matRowDef="columns: displayedColumns"></mat-row>
                 </mat-table>
类型脚本代码是

 displayedColumns = [' Name', 'Mobile'];

addABunch(n: number) {
  for (let x = 0; x < n; x++) {
    this.items.push({ value: ++this.max });
  }
}

我认为这是一个无效的matRowDef声明。用这个代替