My Angular В таблице материалов не отображаются никакие данные. Это также не бросает никаких исключений и не делает ничего странного. Я уже прочитал несколько других сообщений stackoverflow, но не смог найти ничего полезного.
вот что я получаю, когда sortedData содержит 12 объектов вопроса. Как видите, строки отображаются, но не заполнены какими-либо данными
Заранее спасибо!
таблица вопросов. html:
<div class="mat-elevation-z8">
<table *ngIf="sortedData!=null" [dataSource]="sortedData" mat-table class="full-width-table" matSort aria-label="Elements">
<!-- Id Column -->
<ng-container matColumnDef="id">
<mat-header-cell *matHeaderCellDef mat-sort-header>Id</mat-header-cell>
<mat-cell *matCellDef="let element">{{element.id}}</mat-cell>
</ng-container>
<!-- Title Column -->
<ng-container matColumnDef="title">
<mat-header-cell *matHeaderCellDef mat-sort-header>Title</mat-header-cell>
<mat-cell *matCellDef="let element">{{element.title}}</mat-cell>
</ng-container>
<!-- Topic Column -->
<ng-container matColumnDef="topic">
<mat-header-cell *matHeaderCellDef mat-sort-header>Topic</mat-header-cell>
<mat-cell *matCellDef="let element">{{element.topic}}</mat-cell>
</ng-container>
<!-- Subtopic Column -->
<ng-container matColumnDef="subtopic">
<mat-header-cell *matHeaderCellDef mat-sort-header>Subtopic</mat-header-cell>
<mat-cell *matCellDef="let element">{{element.subtopic}}</mat-cell>
</ng-container>
<!-- Type Column -->
<ng-container matColumnDef="type">
<mat-header-cell *matHeaderCellDef mat-sort-header>Type</mat-header-cell>
<mat-cell *matCellDef="let element">{{element.type}}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</table>
<mat-paginator #paginator
[length]="dataSource?.data.length"
[pageIndex]="0"
[pageSize]="50"
[pageSizeOptions]="[25, 50, 100, 250]">
</mat-paginator>
</div>
Интерфейс вопроса:
export interface Question {
id?: number;
title?: string;
demand?: string;
type?: QuestionType;
topic?: string;
subTopic?: string;
points?: number;
imgPath?: string;
marking?: boolean;
added?: boolean;
}
ngOnInit of вопрос-таблицы.ts:
ngOnInit() {
this.questionService.getQuestions().subscribe(data => {
this.questions = data;
this.sortedData = this.questions;
console.log(this.sortedData)
});
}