Angular PrimeNG BlockUI Methods
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 BlockUI Methods in Angular PrimeNG.
The BlockUI Component is used to block the component or the whole page. The methods have different functionality and we can alter the BlockUI component according to the use case.
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: Run the below command to see the output
ng serve --save
Example 1: Below is the example code that illustrates the use of Angular PrimeNG BlockUI Methods to block the whole document.
HTML
<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG BlockUI Methods</h5>
<p-blockUI
[blocked]="geekDocumentBlock">
</p-blockUI>
<button
type="button"
class="p-button-success"
icon="pi pi-code" pButton
pRipple label="Click me Geek!"
(click)="GeekBlock()">
</button>
JavaScript
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
geekPanelBlock: boolean = false;
geekDocumentBlock: boolean = false;
GeekBlock() {
this.geekDocumentBlock = true;
setTimeout(() => {
this.geekDocumentBlock = false;
}, 3000);
}
}
JavaScript
import { NgModule } from '@angular/core';
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: [
BrowserAnimationsModule,
BlockUIModule,
ButtonModule,
PanelModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Output:
Example 2: Below is another example code that illustrates the use of Angular PrimeNG BlockUI Methods to block the Panel.
HTML
<h2 style="color: green">GeeksforGeeks</h2>
<h3>Angular PrimeNG BlockUI Methods</h3>
<button pButton
icon="pi pi-code"
class="mb-4 p-button-success"
label="Block the Panel Geek"
(click)="tempBlock()">
</button>
<br/><br/>
<p-panel #blockTarget header="GeeksforGeeks">
<p>
GeeksforGeeks It is a Computer
Science portal for all geeks.
Here you can share your knowledge
with other geeks through articles.
There are also many courses which
provides you industry ready skills
in affordable pricing.
</p>
</p-panel>
<p-blockUI [target]="blockTarget"
[blocked]="blocked">
<div class="text-center custom-content">
<i class="pi pi-lock"></i>
<p>The panel is blocked for {{time}} seconds</p>
</div>
</p-blockUI>
JavaScript
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styles: [
`.custom-content{
color: black;
background-color: cyan;
padding: 15px;
}`
]
})
export class AppComponent {
blocked: boolean = false;
time = 2;
tempBlock() {
this.blocked = true;
setTimeout(() => {
this.blocked = false;
}, this.time * 1000);
}
}
JavaScript
import { NgModule } from '@angular/core';
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: [
BrowserAnimationsModule,
BlockUIModule,
ButtonModule,
PanelModule,
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Output:
Reference: https://primefaces.org/primeng/blockui
Similar Reads
Angular PrimeNG BlockUI Events 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 about Angular PrimeNG BlockUI Events. The BlockUI component is used to
3 min read
Angular PrimeNG BlockUI Document Angular PrimeNG is a front-end UI toolkit for Angular applications. It has a wide variety of angular components that helps developers to build web applications in less time as they don't have to make everything from scratch. In this article, we will discuss BlockUI Document in Angular PrimeNG. The B
3 min read
Angular PrimeNG BlockUI Component 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 BlockUI component in Angular PrimeNG. BlockUI component
3 min read
Angular PrimeNG Inplace Methods Angular PrimeNG is a UI component library for Angular Applications. It offers many pre-built themes and UI components for a variety of tasks like inputs, menus, charts, Buttons, etc. In this article, we will see Angular PrimeNG Inplace Methods. The Inplace component is used to provide an easy to do
3 min read
Angular PrimeNG BlockUI Panel Angular PrimeNG is a front-end UI toolkit for Angular applications. It has a wide variety of angular components that helps developers to build web applications in less time as they don't have to make everything from scratch. In this article, we will discuss the Angular PrimeNG BlockUI Panel. The Blo
3 min read
Angular PrimeNG BlockUI Custom Content Angular PrimeNG is a front-end UI toolkit for Angular applications. It has a wide variety of angular components that helps developers to build web applications in less time as they don't have to make everything from scratch. In this article, we will see the Angular PrimeNG BlockUI Custom Content. Th
3 min read