Angular 角度材质6:无法读取属性';查找';MathedErrorWDEF表中未定义的

Angular 角度材质6:无法读取属性';查找';MathedErrorWDEF表中未定义的,angular,angular6,Angular,Angular6,使用角材料:6.4.5和角材料:6.4.3 但面对这个问题, 我已经实现了上提供的完全相同的示例 代码 .html 你介意分享你的代码吗。可能缺少了一些内容。没有任何更改,我已复制并粘贴了代码。请看一看,在其中添加了代码。请参见:感谢您的祝福,祝您幸福:) <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" *ngIf="displayedColumns"> <!-- Position C

使用角材料:6.4.5角材料:6.4.3 但面对这个问题,

我已经实现了上提供的完全相同的示例

代码 .html


你介意分享你的代码吗。可能缺少了一些内容。没有任何更改,我已复制并粘贴了代码。请看一看,在其中添加了代码。请参见:感谢您的祝福,祝您幸福:)
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" *ngIf="displayedColumns">
  <!-- Position Column -->
  <ng-container matColumnDef="position">
    <th mat-header-cell *matHeaderCellDef> No. </th>
    <td mat-cell *matCellDef="let element"> {{element.position}} </td>
  </ng-container>

  <!-- Name Column -->
  <ng-container matColumnDef="name">
    <th mat-header-cell *matHeaderCellDef> Name </th>
    <td mat-cell *matCellDef="let element"> {{element.name}} </td>
  </ng-container>

  <!-- Weight Column -->
  <ng-container matColumnDef="weight">
    <th mat-header-cell *matHeaderCellDef> Weight </th>
    <td mat-cell *matCellDef="let element"> {{element.weight}} </td>
  </ng-container>

  <!-- Symbol Column -->
  <ng-container matColumnDef="symbol">
    <th mat-header-cell *matHeaderCellDef> Symbol </th>
    <td mat-cell *matCellDef="let element"> {{element.symbol}} </td>
  </ng-container>

  <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
  <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
export interface PeriodicElement {
  name: string
  position: number
}

const ELEMENT_DATA: PeriodicElement[] = [
  { position: 1, name: 'Hydrogen' },
  { position: 2, name: 'Helium' },
  { position: 3, name: 'Lithium' },
  { position: 4, name: 'Beryllium' },
  { position: 5, name: 'Boron' },
  { position: 6, name: 'Carbon' },
  { position: 7, name: 'Nitrogen' },
  { position: 8, name: 'Oxygen' },
  { position: 9, name: 'Fluorine' },
  { position: 10, name: 'Neon' },
];

@Component({
  selector: 'app-my',
  templateUrl: './my.component.html',
  styleUrls: ['./my.component.scss']
})
export class MyComponent implements OnInit {      
  displayedColumns: string[] = ['position', 'name'];
  dataSource = ELEMENT_DATA;
}