Angular PrimeNG DataView Templates
Last Updated :
28 Apr, 2025
Angular PrimeNG is an open-source framework with a rich set 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 know how to use the DataView Templates in Angular PrimeNG.
The DataView Component is used to display data in a grid and list layout with pagination and sorting features.
Angular PrimeNG DataView Templates:
- header: It is the header component that is used to include the header in the template.
- paginatorleft: It is used in the template to shift the content to the left of the paginator.
- paginatorright: It is used in the template to shift the content to the right of the paginator.
- gridItem: It is used in the template to set the hierarchy of the view into a PropertyGrid.
- footer: It is the footer component that is used to include the footer in the template.
Creating Angular application & module installation:
Step 1: Create an Angular application using the following command.
ng new appname
Step 2: After creating your project folder i.e. appname, move to it using the following command.
cd appname
Step 3: Install PrimeNG in your given directory.
npm install primeng --save
npm install primeicons --save
Project Structure: It will look like the following:
Steps to run the application: To run the above file run the below command:
ng serve --save
Example 1: This is the basic example that shows how to use the DataView Templates using pTemplate="header".
HTML
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG DataView Templates</h5>
<div class="card">
<p-dataView
#dv [value]="gfg" [paginator]="true"
[rows]="4" filterBy="name" layout="grid">
<ng-template pTemplate="header">
<p-dataViewLayoutOptions>
</p-dataViewLayoutOptions>
</ng-template>
<ng-template let-product pTemplate="gridItem">
<div class="p-col-12 p-md-4">
<div class="product-grid-item">
<button pButton pRipple type="button"
label="GeeksforGeeks"
class="p-button-success">
</button>
</div>
</div>
</ng-template>
</p-dataView>
</div>
JavaScript
import { Component } from "@angular/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"],
})
export class AppComponent {
gfg: string[] = [
"gfg1",
"gfg2",
"gfg3",
"gfg4",
"gfg5",
"gfg6",
"gfg7",
"gfg8",
"gfg9",
"gfg10"
];
ngOnInit() {}
}
JavaScript
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { DataViewModule } from "primeng/dataview";
import {ButtonModule} from 'primeng/button';
@NgModule({
imports: [
ButtonModule,
BrowserModule,
BrowserAnimationsModule,
DataViewModule,
HttpClientModule,
FormsModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
Output:
Example 2: This is another basic example that shows how to use the DataView Templates using pTemplate="gridItem".
HTML
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG DataView Templates</h5>
<div class="card">
<p-dataView
#dv [value]="gfg" [paginator]="true"
[rows]="4" filterBy="name" layout="grid">
<ng-template let-product pTemplate="gridItem">
<div class="p-col-12 p-md-4">
<div class="product-grid-item">
<button pButton pRipple type="button"
label="GeeksforGeeks"
class="p-button-success">
</button>
</div>
</div>
</ng-template>
</p-dataView>
</div>
JavaScript
import { Component } from "@angular/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"],
})
export class AppComponent {
gfg: string[] = [
"gfg1",
"gfg2",
"gfg3",
"gfg4",
"gfg5",
"gfg6",
"gfg7",
"gfg8",
"gfg9",
"gfg10"
];
ngOnInit() {}
}
JavaScript
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { DataViewModule } from "primeng/dataview";
import {ButtonModule} from 'primeng/button';
@NgModule({
imports: [
ButtonModule,
BrowserModule,
BrowserAnimationsModule,
DataViewModule,
HttpClientModule,
FormsModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
Output:
Reference: https://primefaces.org/primeng/dataview
Similar Reads
Angular PrimeNG Panel Templates Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use the Panel Templates in Angular PrimeNG. The Panel Component all
4 min read
Angular PrimeNG Dialog Templates Angular PrimeNG is an open-source framework with a rich set 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 know how to use the Dialog Templates in Angular PrimeNG. The Dialog Compone
3 min read
Angular PrimeNG Inplace Templates Angular PrimeNG is a UI component catalog for angular applications. It consists of a wide range of UI components that help in making fast and scalable websites. In this article, we will see Inplace Templates in Angular PrimeNG. The Inplace component is used to edit and display the content in place o
3 min read
Angular PrimeNG Card Templates Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use the Card Templates in Angular PrimeNG. The Card Component is us
3 min read
Angular PrimeNG DataView Styling Angular PrimeNG is an open-source framework with a rich set 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 know how to use the DataView Styling in Angular PrimeNG. The DataView Compo
3 min read
Angular PrimeNG Galleria Templates Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more.
4 min read
Angular PrimeNG Fieldset Templates Angular PrimeNG is an open-source framework with a rich set 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 use the different available Fieldset Templates in Angular PrimeN
3 min read
Angular PrimeNG Carousel Templates Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. It provides a lot of templates, components, theme design, an extensive icon library, and much more.
4 min read
Angular PrimeNG OrderList Templates Angular PrimeNG is an open-source framework with a rich set 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 learn about Angular PrimeNG OrderList Templates. The Orderlist component is
3 min read
Angular PrimeNG FileUpload Templates Angular PrimeNG is an open-source framework with a rich set 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 know how to use FileUpload Templates in Angular PrimeNG. The FileUpload Com
3 min read