Open In App

Angular PrimeNG PanelMenu Properties

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:

 



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.




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




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',
                  },
              ],
            },
        ];
    }
}




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”.




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




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',
                    },
                ],
            },
        ];
    }
}




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


Article Tags :