import {BlockUIModule} from 'primeng/primeng';
BlockUI is controlled using the blocked property and component to block is defined as target. If target is not provided, document itself is selected as the block target.
export class BlockUIDemo {
blocked: boolean;
}
<p-blockUI [blocked]="blocked"></p-blockUI>
To block a certain component, define a local template variable and bind it to the target option. The target component must implement the BlockableUI interface, otherwise an exception is thrown.
<p-blockUI [blocked]="blockedDocument" [target]="pnl"></p-blockUI>
<p-panel #pnl header="Panel Header">
Content of Panel
</p-panel>
Name | Type | Default | Description |
---|---|---|---|
blocked | boolean | false | Controls the blocked state. |
target | any | document | Name of the local template variable referring to another component. |
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
ui-blockui | Container element. |
None.
export class BlockUIDemo {
blockedPanel: boolean = false;
blockedDocument: boolean = false;
blockDocument() {
this.blockedDocument = true;
setTimeout(() => {
this.blockedDocument = false;
}, 3000);
}
}
<h3 class="first">Document</h3>
<p-blockUI [blocked]="blockedDocument"></p-blockUI>
<button type="button" pButton label="Block" (click)="blockDocument()"></button>
<h3>Panel</h3>
<button type="button" pButton label="Block" (click)="blockedPanel=true"></button>
<button type="button" pButton label="Unblock" (click)="blockedPanel=false"></button>
<p-blockUI [target]="pnl" [blocked]="blockedPanel"></p-blockUI>
<p-panel #pnl header="Godfather I" [style]="{'margin-top':'20px'}">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
</p-panel>