Open In App

Angular PrimeNG Slide Menu 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 see how to use SlideMenu Properties in Angular PrimeNG. We will also learn about the properties, along with their syntaxes that will be used in the code.

The SlideMenu component is used to display the menu list in the form of a sliding animation which helps to see the menu items in a stepwise manner.



Angular PrimeNG Slide Menu 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 the 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 shows how to use Angular PrimeNG SlideMenu Properties.




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




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

Output:

 

Example 2: This is another basic example that shows how to use Angular PrimeNG SlideMenu Properties using a button popup.




<h1 style="color:green">GeeksforGeeks</h1>
<h5>PrimeNG SlideMenu Properties</h5>
  
<button #btn type="button" pButton 
    label="GeeksforGeeks"
    (click)="menu.toggle($event)">
</button>
    
<p-slideMenu #menu 
    [model]="gfg" [popup]="true" 
    [viewportHeight]="250">
</p-slideMenu>




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

Output:

 

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


Article Tags :