Angular PrimeNG BlockUI 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 Angular PrimeNG BlockUI Templates
BlockUI component is used to block the component or the whole page. Angular PrimeNG BlockUI Templates are used to put some content on some pre-structured containers. BlockUI templates are discussed below:
- content: This template is used to create content for the BlockUI.
Syntax:
<p-blockUI [blocked]="...">
<ng-template pTemplate="content" let-node>
...
</ng-template>
</p-blockUI>
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:
Example 1: In this example, we will learn about BlockUI Templates. In the content template, we will display a heading and lock-icon.
app.component.html
HTML
<div>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h2>
Angular PrimeNG BlockUI Templates
</h2>
<p-blockUI [blocked]="gfg">
<ng-template pTemplate="content" let-node>
<h1>I am Blocked Now </h1>
<i class="pi pi-lock" style="font-size: 3rem"></i>
</ng-template>
</p-blockUI>
<button type="button" pButton pRipple
label="Click here to block" (click)="geeks()">
</button>
</div>
app.component.ts
JavaScript
import { Component } from "@angular/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
})
export class AppComponent {
gfg: boolean = false;
geeks() {
this.gfg = true;
setTimeout(() => {
this.gfg = false;
}, 3000);
}
}
app.module.ts
JavaScript
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { ButtonModule } from "primeng/button";
import { BlockUIModule } from "primeng/blockui";
import { PanelModule } from "primeng/panel";
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
BlockUIModule,
ButtonModule,
PanelModule,
FormsModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule { }
Output:
Example 2: In this example, we will use a ng-template variable to block a certain part and define content template.
app.component.html
HTML
<div style="width:50%">
<h1 style="color:green">
GeeksforGeeks
</h1>
<h2>
Angular PrimeNG BlockUI Templates
</h2>
<p-blockUI [target]="pnl" [blocked]="gfg">
<ng-template pTemplate="content" let-node>
<h3>I am Blocked Now </h3>
<i class="pi pi-lock" style="font-size: 3rem"></i>
</ng-template>
</p-blockUI>
<p-panel #pnl header="GeeksforGeeks">
GeeksforGeeks is a computer science portal
</p-panel>
<br>
<button type="button" pButton pRipple
label="Click here to block" (click)="geeks()">
</button>
</div>
app.component.ts
JavaScript
import { Component } from "@angular/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
})
export class AppComponent {
gfg: boolean = false;
geeks() {
this.gfg = true;
setTimeout(() => {
this.gfg = false;
}, 3000);
}
}
app.module.ts
JavaScript
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { BrowserAnimationsModule }
from "@angular/platform-browser/animations";
import { AppComponent } from "./app.component";
import { ButtonModule } from "primeng/button";
import { BlockUIModule } from "primeng/blockui";
import { PanelModule } from "primeng/panel";
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
BlockUIModule,
ButtonModule,
PanelModule,
FormsModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule { }
Output:
Reference: https://primefaces.org/primeng/blockui
Similar Reads
Angular PrimeNG PickList 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 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 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 Button 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 style the Tooltip component in Angular PrimeNG. A Button is general
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 BlockUI Properties 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 how to use BlockUI Properties in Angular PrimeNG. We will also learn
4 min read
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 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 Image Templates 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 discuss Angular PrimeNG Image Templates. The Image Component is used to show an
3 min read