Open In App

Angular PrimeNG Table EmptyMessage

Last Updated : 13 Sep, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Angular PrimeNG is an open-source library that consists of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to display Table EmptyMessage in Angular PrimeNG.

The Table Component shows some data to the user in tabular form. When there is no data to display in the table, the emptymessage template can be used to show a custom message to let the user know that there is no data to display.

Syntax:

<p-table [value]="..."[scrollable]="true | false">
    <ng-template pTemplate="header">
        ...
    </ng-template>
    
    <ng-template pTemplate="body">
        ...
    </ng-template>
    
    <ng-template pTemplate="emptymessage">
        <tr>
            <td>Write-EmptyMessage-Here</td>
        </tr>
    </ng-template>
</p-table>

Creating Angular application and Installing the Modules:

Step 1: Create an Angular application using the following command.

ng new myapp

Step 2: After creating your project folder i.e. myapp, move to it using the following command.

cd myapp

Step 3: Install PrimeNG in your given directory.

npm install primeng --save
npm install primeicons --save

Project Structure: After completing the above steps the project structure will look like the following.

Project Structure

Example 1: This article shows the use of the emptymessage template to show an empty message where there is no data in the table.

app.component.html

 
app.component.ts

 
app.module.ts

 

Output:

 

Example 2: This is another example to show an empty message. In this example, initially, there are some records in the table, but when those records are removed, the empty message becomes visible.

app.component.html

 
app.component.ts

 
app.module.ts

 

Output:

 

Reference: http://primefaces.org/primeng/table


Like Article
Suggest improvement
Next
Share your thoughts in the comments

Similar Reads

Angular PrimeNG TreeTable EmptyMessage
Angular PrimeNG Table Column Widths of a Scrollable Table
Angular PrimeNG Table Paginator
Angular PrimeNG Table Selection
Angular PrimeNG Table Dynamic Columns
Angular PrimeNG Table Separate Row and Filter Menu
Angular PrimeNG Table ColumnFilter Properties
Angular PrimeNG Table Full Page Scroll
Angular PrimeNG Table ContextMenu
Angular PrimeNG Table Loading Status