Angular PrimeNG BlockUI Properties
Last Updated :
31 Oct, 2022
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 about the properties, along with their syntaxes that will be used in the code.
The BlockUI Component is used to block the component or the whole page.
Angular PrimeNG BlockUI Properties:
- blocked: It is used to control the blocked state. It is of the boolean data type, the default value is false.
- target: It is used to define the name of the local ng-template variable referring to another component. It is of string data type, the default value documents.
- baseZIndex: It is used to define the base z-Index value to use in layering. It is of number data type, the default value is 0.
- autoZIndex: It is used to whether to automatically manage the layering. It is of a boolean data type, and the default value is true.
- styleClass: It is used to define the style class of the component. It is of string data type, the default value is false.
Syntax:
<p-blockUI [blocked]="blocked">
...
</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: After complete installation, it will look like the following:
- To run the above file run the below command:
ng serve --save
Example 1: This is the basic example that shows how to use Angular PrimeNG BlockUI Properties.
HTML
< h2 style = "color: green" >GeeksforGeeks</ h2 >
< h5 >Angular PrimeNG BlockUI Properties</ h5 >
< button type = "button"
pButton
pRipple
label = "Block"
(click)=" gfg = true ">
</ button >
< button type = "button"
pButton
pRipple
label = "Unblock"
(click)=" gfg = false ">
</ button >
< p-blockUI [target]="geeks"
[blocked]="gfg">
< i class = "pi pi-lock"
style = "font-size: 3rem" >
</ i >
</ p-blockUI >
< p-panel #geeks header = "GeeksforGeeks"
styleClass = "p-mt-4" >
< p class = "p-m-0" >
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 >
|
Javascript
import { Component } from "@angular/core" ;
@Component({
selector: "app-root" ,
templateUrl: "./app.component.html" ,
})
export class AppComponent {
gfg: boolean = false ;
}
|
Javascript
import { NgModule } from '@angular/core' ;
import { BrowserModule }
from '@angular/platform-browser' ;
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations' ;
import { AppComponent } from './app.component' ;
import { BlockUIModule } from 'primeng/blockui' ;
import { PanelModule } from 'primeng/panel' ;
import { ButtonModule } from 'primeng/button' ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
BlockUIModule,
ButtonModule,
PanelModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule { }
|
Output:
Example 2: This is another basic example that shows how to use Angular PrimeNG BlockUI Properties.
HTML
< h2 style = "color: green" >GeeksforGeeks</ h2 >
< h3 >Angular PrimeNG BlockUI Properties</ h3 >
< button pButton
class = "mb-4"
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: white;
background-color: red;
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 { BrowserModule }
from '@angular/platform-browser' ;
import { BrowserAnimationsModule }
from '@angular/platform-browser/animations' ;
import { AppComponent } from './app.component' ;
import { BlockUIModule } from 'primeng/blockui' ;
import { PanelModule } from 'primeng/panel' ;
import { ButtonModule } from 'primeng/button' ;
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
BlockUIModule,
ButtonModule,
PanelModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule { }
|
Output:
Reference: https://primefaces.org/primeng/blockui
Share your thoughts in the comments
Please Login to comment...