Open In App

Angular PrimeNG Panel Header and Footer Content

Last Updated : 19 Oct, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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 Header and Footer Content in Angular PrimeNG. We will also learn about the properties, along with their syntaxes that will be used in the code.

The Panel Component allows us to make an element containing a header and some content associated with that header.

Syntax:

<p-panel >
    <ng-template pTemplate="header">
        .....
    </ng-template>
        .....
    <ng-template pTemplate="footer">
        .....
    </ng-template>
</p-panel>

 

Angular PrimeNG Panel Header and Footer Content Properties:

  • header: It is the header text of the panel. It is of string data type, the default value is null.
  • toggleable: It defines whether the content of the panel can be expanded and collapsed or not. It is of boolean data type, the default value is false.

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:

ng serve --open

Example 1: Below is the basic example demonstrating the use of Angular PrimeNG Panel Header and Footer Content.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Panel Header and Footer Content</h5>
  
<p-panel [toggleable]="true">
    <ng-template pTemplate="header">
        GeeksforGeeks Header
    </ng-template>
  
    <p>
        Angular PrimeNG is a framework used with angular to create
        components with great styling and this framework is very
        easy to use and is used to make responsive websites.
    </p>
      
    <ng-template pTemplate="footer">
        GeeksforGeeks Footer
    </ng-template>
</p-panel>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
import { MessageService } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    providers: [MessageService],
})
  
export class AppComponent {}


  • app.module.ts:

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 { PanelModule } from 'primeng/panel';
import { ToastModule } from 'primeng/toast';
import { ButtonModule } from 'primeng/button';
import { MenuModule } from 'primeng/menu';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PanelModule,
        ToastModule,
        ButtonModule,
        MenuModule,
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule {}


Output:

 

Example 2: Below is another example demonstrating the use of Angular PrimeNG Panel Header and Footer Content using an image.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Panel Header and Footer Content</h5>
  
<p-panel [toggleable]="true">
    <ng-template pTemplate="header">
        GeeksforGeeks Header
    </ng-template>
  
    <p>
        <img alt="gfg" height="200px" src=
  
        <img alt="gfg" height="200px" src=
    </p>
  
    <ng-template pTemplate="footer">
        GeeksforGeeks Footer
    </ng-template>
</p-panel>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
import { MessageService } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    providers: [MessageService],
})
  
export class AppComponent {}


  • app.module.ts:

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 { PanelModule } from 'primeng/panel';
import { ToastModule } from 'primeng/toast';
import { ButtonModule } from 'primeng/button';
import { MenuModule } from 'primeng/menu';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PanelModule,
        ToastModule,
        ButtonModule,
        MenuModule,
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule {}


Output:

 

Reference: https://primefaces.org/primeng/panel



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads