Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrimeNG data table not displaying in angular 2

I am trying to display a basic data table but cannot seem to get it working even though I've read through the documentation. I am not getting any console errors, the table just does not display. I am able to get some of the other prime ng components to work so I assume there is nothing wrong with my setup.

I have an array declared in my component that looks like this:

this.employees = [
    {"firstName":"John", "lastName":"Doe"},
    {"firstName":"Anna", "lastName":"Smith"},
    {"firstName":"Peter","lastName":"Jones"}
];

In my template I have this:

<p-dataTable [value]="employees">
    <p-column field="firstName" header="First Name"></p-column>
    <p-column field="lastName" header="Last Name"></p-column>
</p-dataTable>

Perhaps I have misunderstood the documentation and there is something wrong with either my array or my template? Thanks

like image 321
Mark Letters Avatar asked May 10 '16 10:05

Mark Letters


1 Answers

I figured out what the problem was. I just forgot to add the DataTable and Column directives to the component. It works fine after including them

like image 137
Mark Letters Avatar answered Nov 15 '22 06:11

Mark Letters