Open In App

Angular PrimeNG Panel Regular

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 Regular 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 header="....">
    <p>.....</p>
</p-panel>

 

Angular PrimeNG Panel Regular Properties:

  • header: It is the header text of the panel. It is of string data type, the default value is null.

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:

ng serve --open

Example 1: Below is the basic example demonstrating the use of Angular PrimeNG Panel Regular.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Panel Regular</h5>
<p-panel header="GeeksforGeeks">
    <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>
</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';
  
@NgModule({
  imports: [
      BrowserModule, 
      BrowserAnimationsModule, 
      PanelModule
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}


Output:

 

Example 2: Below is another example demonstrating the use of Angular PrimeNG Panel Regular using an image.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angular PrimeNG Panel Regular</h5>
<p-panel header="GeeksforGeeks">
    <p>
           <img alt="gfg" height="200px" src=
    </p>
</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';
  
@NgModule({
  imports: [
      BrowserModule, 
      BrowserAnimationsModule, 
      PanelModule
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}


Output:

 

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



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads