Angular PrimeNG Dialog Header and Footer
source link: https://www.geeksforgeeks.org/angular-primeng-dialog-header-and-footer/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Angular PrimeNG Dialog Header and Footer
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 Dialog Header and Footer inAngular PrimeNG.We will also learn about the properties along with their syntaxes that will be used in the code.
Dialog component is used to make a component containing some content to display in an overlay window. Using header and footer templates, header and footer sections may be customized.
Angular PrimeNG Dialog Header and Footer Properties:
- header: It is the title text of the dialog. It is of string data type, the default value is null.
- position: It is used to set the position of the dialog. It is of string data type, the default value is center.
- visible: It specifies the visibility of the dialog. It is of the boolean data type, the default value is false.
Syntax:
<p-dialog position="..." header="...." [(visible)]="..."> <ng-template pTemplate="header || footer"> ... </ng-template> </p-dialog> <p-button (click)="..." label="..."> </p-button>
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:
- Run the below command to see the output:
ng serve --open
Example 1: Below is the code example that illustrates the use of Angular PrimeNG Dialog Header and Footer using the pTemplate=”header”.
- app.component.html
< div style = "text-align: center" > < h2 style = "color: green" >GeeksforGeeks</ h2 > < h5 >PrimeNG Dialog Header and Footer</ h5 > < p-dialog position = "center" header = "GeeksforGeeks" [(visible)]="geeks"> < ng-template pTemplate = "header" > Hey Geek, I'm the header! </ ng-template > < p > Hi GfG you are the complete computer science portal for geeks. </ p > </ p-dialog > < p-button (click)="gfg()" label = "Click Here" > </ p-button > </ div > |
- app.component.ts
import { Component } from "@angular/core" ; import { PrimeNGConfig } from "primeng/api" ; @Component({ selector: "app-root" , templateUrl: "./app.component.html" , }) export class AppComponent { constructor(private primengConfig: PrimeNGConfig) {} ngOnInit() { this .primengConfig.ripple = true ; } geeks: boolean; gfg() { this .geeks = true ; } } |
- app.module.ts
import { NgModule } from "@angular/core" ; import { BrowserModule } from "@angular/platform-browser" ; import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ; import { AppComponent } from "./app.component" ; import { DialogModule } from "primeng/dialog" ; import { ButtonModule } from "primeng/button" ; @NgModule({ imports: [BrowserModule, BrowserAnimationsModule, DialogModule, ButtonModule], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule {} |
Output:
Example 2: Below is another code example that illustrates the use of Angular PrimeNG Dialog Header and Footer using the pTemplate=”footer”.
- app.component.html
< div style = "text-align: center" > < h2 style = "color: green" >GeeksforGeeks</ h2 > < h5 >PrimeNG Dialog Header and Footer</ h5 > < p-dialog position = "center" header = "GeeksforGeeks" [(visible)]="geeks"> < ng-template pTemplate = "footer" > Hey Geek, I'm the footer! </ ng-template > < p > Hi GfG you are the complete computer science portal for geeks. </ p > </ p-dialog > < p-button (click)="gfg()" label = "Click Here" > </ p-button > </ div > |
- app.component.ts
import { Component } from "@angular/core" ; import { PrimeNGConfig } from "primeng/api" ; @Component({ selector: "app-root" , templateUrl: "./app.component.html" , }) export class AppComponent { constructor(private primengConfig: PrimeNGConfig) {} ngOnInit() { this .primengConfig.ripple = true ; } geeks: boolean; gfg() { this .geeks = true ; } } |
- app.module.ts
import { NgModule } from "@angular/core" ; import { BrowserModule } from "@angular/platform-browser" ; import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ; import { AppComponent } from "./app.component" ; import { DialogModule } from "primeng/dialog" ; import { ButtonModule } from "primeng/button" ; @NgModule({ imports: [BrowserModule, BrowserAnimationsModule, DialogModule, ButtonModule], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule {} |
Output:
Reference: https://primefaces.org/primeng/dialog
“This course was packed with amazing and well-organized content! The project-based approach of this course made it even better to understand concepts faster. Also the instructor in the live classes is really good and knowledgeable.”- Tejas | Deutsche Bank
With our revamped Full Stack Development Program: master Node.js and React that enables you to create dynamic web applications.
So get ready for salary hike only with our Full Stack Development Course.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK