taxioma
taxioma

Reputation: 13

No data in mat-table

Work in Angular 2+. This is my project. https://stackblitz.com/edit/angular-v8tdaz I dont know what is wrong, but my mat-table not display its content. I see sort, paginator, filter...but not see data in table.

I see data in console

0: {fieldDate: "Fri May 18 2018 17:38:35 GMT+0300 (RTZ 2 (зима))", fieldHost: "192.168.32.30", fieldEvent: "Active", fieldComent: "Its OK", fieldResult: "true"}
1: {fieldDate: "Fri May 18 2018 17:38:35 GMT+0300 (RTZ 2 (зима))", fieldHost: "192.168.30.47", fieldEvent: "Bug", fieldComent: "Smth wrong", fieldResult: "false"}
length: 2

But in HTML its empty

<mat-row _ngcontent-c1="" class="mat-row ng-star-inserted" role="row">
<!---->
</mat-row>

I try display non-material tags in table, its not display too. I suppose, that version of my lib is wrong, but it dosnt work.

Can you help me?

Upvotes: 1

Views: 1894

Answers (1)

Ravi Sankar Rao
Ravi Sankar Rao

Reputation: 1070

There are a couple of things in your project

Firstly, public displayedColumns: ['fieldDate', 'fieldHost', 'fieldEvent', 'fieldComent', 'fieldResult'];

That's not how you assign a string array. I guess you did a syntactical error here. Instead of = you provided :

So, it should be

public displayedColumns = ['fieldDate', 'fieldHost', 'fieldEvent', 'fieldComent', 'fieldResult'];

Second, the displayedColumns should contain only those columns which you want to display. In your case you are displaying only fieldDate column in HTML, and setting 5 columns in the array.

So, this should be

public displayedColumns = ['fieldDate'];

Here's the working solution for your project - Solution

Upvotes: 2

Related Questions