PrimeNG datasheet not displayed in angular 2

I am trying to display a basic data table but cannot make it work even if I read the documentation. I do not get any console errors, the table just does not appear. I can get some of the other simple 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 the following:

 <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 misunderstood the documentation and there is something wrong with my array or with my template? Thanks

+5
source share
1 answer

I realized what the problem is. I just forgot to add the DataTable and Column directives to the component. It works fine after they are turned on.

+7
source

All Articles