Angular PrimeNG Table EmptyMessage

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