Open In App

Angular PrimeNG PanelMenu Properties

Last Updated : 07 Nov, 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. In this article, we will learn how to use the PanelMenu Properties in Angular PrimeNG. We will also learn about the properties, along with their syntaxes that will be used in the code.

The PanelMenu Component is used to make a menu in the form of a panel. It can be considered as a combination of accordion and tree components

Angular PrimeNG PanelMenu Properties:

  • model: It is an array of menu items. It accepts the array data type as input & the default value is null.
  • style: It is used to set an inline style of the component. It is of the string data type & the default value is null.
  • styleClass: It is used to set the style class of the component. It is of the string data type & the default value is null.
  • multiple: It is used to specify whether multiple tabs can be activated at the same time or not. It is of the boolean data type & the default value is true.
  • transitionOptions: It is used to set the transition options of the animation. It is of the string data type & the default value is 400ms cubic-bezier(0.86, 0, 0.07, 1).

 

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:

 

Steps to run the application: To run the above file, run the below command:

ng serve --save

Example 1: This is the basic example that illustrates how to use the Angular PrimeNG PanelMenu Properties.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angualar PrimeNG PanelMenu Properties</h5>
<p-panelMenu [model]="gfg"></p-panelMenu>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
import { MenuItem } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
  
export class AppComponent {
    gfg: MenuItem[];
  
    ngOnInit() {
        this.gfg = [
            {
              label: 'HTML',
              items: [
                  {
                    label: 'HTML 1',
                  },
                  {
                    label: 'HTML 2',
                  },
              ],
            },
            {
              label: 'Angular',
  
              items: [
                  {
                    label: 'Angular 1',
                  },
                  {
                    label: 'Angular 2',
                  },
              ],
            },
        ];
    }
}


  • 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 { PanelMenuModule } from 'primeng/panelmenu';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PanelMenuModule,
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

Example 2: This is another basic example that illustrates how to use the Angular PrimeNG PanelMenu Properties using multiple=”false”.

  • app.component.html:

HTML




<h1 style="color: green">GeeksforGeeks</h1>
<h5>Angualar PrimeNG PanelMenu Properties</h5>
<p-panelMenu [multiple]='false' [model]="gfg"></p-panelMenu>


  • app.component.ts:

Javascript




import { Component } from '@angular/core';
import { MenuItem } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
})
  
export class AppComponent {
    gfg: MenuItem[];
  
    ngOnInit() {
        this.gfg = [
            {
              label: 'Courses',
              icon: 'pi pi-pencil',
              items: [
                  {
                    label: 'DSA-Self Paced',
                  },
                  {
                    label: 'System Design',
                  },
              ],
            },
            {
              label: 'Tutorials',
              icon: 'pi pi-youtube',
              items: [
                  {
                    label: 'Angular Js',
                  },
                  {
                    label: 'React Js',
                  },
              ],
            },
            {
                label: 'Jobs',
                icon: 'pi pi-id-card',
                items: [
                    {
                      label: 'GfG Jobathon',
                    },
                    {
                      label: 'Post a Job',
                    },
                ],
            },
            {
                label: 'Practice',
                icon: 'pi pi-code',
                items: [
                    {
                      label: 'Problem of the day',
                    },
                    {
                      label: 'SDE Sheet',
                    },
                ],
            },
        ];
    }
}


  • 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 { PanelMenuModule } from 'primeng/panelmenu';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        PanelMenuModule,
    ],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
})
  
export class AppModule { }


Output:

 

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



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

Similar Reads