Таблица данных моего углового материала вообще не отображается. В консоли нет ошибок. Я могу видеть HTML-разметку в исходном коде страницы и tr, но на экране ничего не отображается. Как вы можете видеть, у меня есть два элемента в моем источнике данных, и два htrs генерируются в html. Я пытался с различными источниками данных без успеха.
Вот мой код
<div class="mat-elevation-z8">
<mat-table [dataSource]="myGuests">
<ng-container matColumnDef="Name">
<th mat-header-cell *matHeaderCellDef>Name</th>
<td mat-cell *matCellDef="let guest"> {{ guest.Name }}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="columnsToDisplay"></tr>
<tr mat-row *matRowDef="let row; columns: columnsToDisplay"></tr>
</mat-table>
</div>
Angular Component
import { Component } from '@angular/core';
import { Guest } from '../models/Guest.model';
import { Title } from '@angular/platform-browser';
import { MatTableDataSource } from '@angular/material';
@Component({
selector: 'manage-guests',
templateUrl: './manage-guests.component.html'
})
export class ManageGuestsComponent {
columnsToDisplay = ['Name'];
myGuests: Guest[];
constructor(private service: GuestService, private title: Title) {
title.setTitle('Ahmad Faiq Ateel - Manage Guests');
this.myGuests = [
{Id: 1, Name: 'Taha', Email: '', Public: true, SignDateTime: new Date(2019, 1, 1) },
{Id: 2, Name: 'Faiq', Email: '', Public: true, SignDateTime: new Date(2019, 1, 1) },
];
}
}
Package.json
{
"name": "ahmad-faiq-ateel-ui",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.11",
"@angular/cdk": "^5.2.5",
"@angular/common": "~5.0.1",
"@angular/compiler": "~5.0.1",
"@angular/core": "~5.0.1",
"@angular/forms": "~5.0.1",
"@angular/http": "~5.0.1",
"@angular/material": "^5.2.5",
"@angular/platform-browser": "~5.0.1",
"@angular/platform-browser-dynamic": "~5.0.1",
"@angular/router": "~5.0.1",
"angular-in-memory-web-api": "~0.5.1",
"bootstrap": "^4.3.1",
"core-js": "^2.5.1",
"jquery": "^3.4.1",
"ngx-toastr": "^8.10.2",
"popper.js": "^1.15.0",
"rxjs": "5.5.2",
"systemjs": "0.20.19",
"zone.js": "^0.8.18"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.12.0",
"@angular/cli": "^7.2.4",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}