0

これが私のAngularプロジェクト構成です。

"@angular/cdk": "^5.2.0",
"@angular/common": "~5.2.6",
"@angular/compiler": "~5.2.6",
"@angular/core": "~5.2.6",
"@angular/forms": "~5.2.6",
"@angular/http": "~5.2.6",
"@angular/material": "^5.2.0"

私は角材を使用してデータのテーブルを作成しています。https://material.angular.io/components/table/examplesの例に従っています。コードは例とほぼ同じですが、テーブルはそうではありません何でも見せます。

コードは次のとおりです。

TSコード

export class ordersComponent {

  displayedColumns =['position', 'name', 'weight', 'symbol'];

  //dataSource = new MatTableDataSource<PeriodicElement>(ELEMENT_DATA);
  dataSource = ELEMENT_DATA;

}

export interface PeriodicElement {
  name: string;
  position: number;
  weight: number;
  symbol: string;
}

const ELEMENT_DATA : PeriodicElement[]= [
   {position: 1, name: 'Hydrogen', weight: 1.0079, symbol: 'H'},
   {position: 2, name: 'Helium', weight: 4.0026, symbol: 'He'},
   {position: 3, name: 'Li: PeriodicElement[]thium', weight: 6.941, symbol: 'Li'},
   {position: 4, name: 'Beryllium', weight: 9.0122, symbol: 'Be'}
 ];

htmlコードは

 <div class="mat-elevation-z8">
   <mat-table mat-table [dataSource]="dataSource">

     <ng-container matColumnDef="position">
       <th mat-header-cell *matHeaderCellDef> No. </th>
       <td mat-cell *matCellDef="let element">  </td>
     </ng-container>
     <ng-container matColumnDef="name">
       <th mat-header-cell *matHeaderCellDef> Name </th>
       <td mat-cell *matCellDef="let element">  </td>
     </ng-container>
     <ng-container matColumnDef="weight">
       <th mat-header-cell *matHeaderCellDef> Weight </th>
       <td mat-cell *matCellDef="let element">  </td>
     </ng-container>
     <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>
   </mat-table>

 </div>

html を調べたところ、html が 4 つの正確なテーブル html 要素を生成していることがわかりましたが、各 html 要素にデータが表示されないのはなぜですか?

ここに画像の説明を入力

最終結果

4

1 に答える 1