Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • AngularJS Tutorial
  • AngularJS Directives
  • AngularJS Functions
  • AngularJS Filters
  • AngularJS Examples
  • AngularJS Interview Questions
  • Angular ngx Bootstrap
  • AngularJS Cheat Sheet
  • AngularJS PrimeNG
  • JavaScript
  • Web Technology
Open In App
Next Article:
Angular PrimeNG SplitButton Events
Next article icon

Angular PrimeNG MenuModel API MenuItem

Last Updated : 24 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
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 see how to use Angular PrimeNG MenuModel API MenuItem.

MenuModel API: PrimeNG menus components share a common API to specify the menuitems and submenus.

The MenuItem class defines various options, like the label, icon, and children of an item in a menu. 

Syntax:

export class MenuDemo {        private items: MenuItem[];        ngOnInit() {          this.gfg= [{              label: '...',              items: [                                ]          }]        }  }

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:

Example 1: In this example, we will create a MenuItem such that label contains an HTML value rather than the string.

  • app.component.html
HTML
<div style="width:80%">     <h1 style="color: green;">         GeeksforGeeks     </h1>     <h2>         Angular PrimeNG MenuModel API MenuItem     </h2>     <p-menu [model]="gfg"></p-menu> </div> 
  • 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:              '<div class="card"> <div class="card-header">HTML</div></div>',                 items: [                     {                         label: 'HTML 1'                     },                     {                         label: 'HTML 2'                     }                 ],                 escape: false             },             {                 label:             '<div class="card"> <div class="card-header">Angular</div></div>',                  items: [                     {                         label: 'Angular 1'                     },                     {                         label: 'Angular 2'                     }                 ],                 escape: false             }         ];     } } 
  • 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 { MenuModule } from 'primeng/menu';  @NgModule({     imports: [BrowserModule,               BrowserAnimationsModule,               MenuModule],     declarations: [AppComponent],     bootstrap: [AppComponent] }) export class AppModule { } 

Output:

Example 2: In this example, we will create MenuItem with icons.

  • app.component.html
HTML
<div style="width:80%">     <h1 style="color: green;">         GeeksforGeeks     </h1>     <h2>         Angular PrimeNG MenuModel API MenuItem     </h2>     <p-menu [model]="gfg"></p-menu> </div> 
  • 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: "Home",                 icon: "pi pi-home"             },             {                 label: "About Us",                 icon: "pi pi-info"             },             {                 label: "Contact",                 icon: "pi pi-phone"             }         ];     } } 
  • 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 { MenuModule } from 'primeng/menu';  @NgModule({     imports: [BrowserModule,               BrowserAnimationsModule,               MenuModule],     declarations: [AppComponent],     bootstrap: [AppComponent] }) export class AppModule { } 

Output:

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


Next Article
Angular PrimeNG SplitButton Events
author
17bcs5e9h
Improve
Article Tags :
  • Technical Scripter
  • Web Technologies
  • AngularJS
  • Technical Scripter 2022
  • Angular-PrimeNG
  • PrimeNG-Menu

Similar Reads

    Button Component

    • Angular PrimeNG Button Basic Component
      Angular PrimeNG is an open-source front-end UI library that has many native Angular UI components which help developers to build a fast and scalable web solution. In this article, we will see Angular PrimeNG Button Basic Component. A Button component is used for carrying out some action when clicked
      3 min read

    • Angular PrimeNG Button Icons Component
      Angular PrimeNG is an open-source front-end UI library that has many native Angular UI components which help developers to build a fast and scalable web solution. In this article, we will be see the Button Icons Component in Angular PrimeNG. A Button Component is used for carrying out some action wh
      3 min read

    • Angular PrimeNG Button Severities Component
      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 the Button Severities Component in Angular PrimeNG. A Button is general
      3 min read

    • Angular PrimeNG Button Raised Buttons Component
      Angular PrimeNG is a UI component library for Angular Applications. It offers many pre-built themes and UI components for a variety of tasks like inputs, menus, charts, Buttons, etc. In this article, we will see Angular PrimeNG Button Raised Buttons Component. A Button component is used for carrying
      3 min read

    • Angular PrimeNG Button Rounded Buttons Component
      Angular PrimeNG is an open-source library that consists 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 be seeing Angular PrimeNG Button Rounded Buttons Component. A Button component
      3 min read

    • Angular PrimeNG Button Text Buttons Component
      Angular PrimeNG is an open-source front-end UI library that has many native Angular UI components which help developers to build a fast and scalable web solution. In this article, we will be seeing Angular PrimeNG Button Text Buttons Component. A Button component is used for carrying out some action
      3 min read

    • Angular PrimeNG Button Label
      Angular PrimeNG is a UI component library for Angular Applications. It offers many pre-built themes and UI components for a variety of tasks like inputs, menus, charts, Buttons, etc. In this article, we will be seeing Angular PrimeNG Button Label.  A Button component is used for carrying out some ac
      3 min read

    • Angular PrimeNG Button Events
      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 style the Tooltip component in Angular PrimeNG. A Button is general
      4 min read

    • Angular PrimeNG Button Severity Component
      Angular PrimeNG is an open-source library that consists 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 be seeing Angular PrimeNG Button Severity Component. A Button component is used
      3 min read

    • Angular PrimeNG Button Text Buttons Component
      Angular PrimeNG is an open-source front-end UI library that has many native Angular UI components which help developers to build a fast and scalable web solution. In this article, we will be seeing Angular PrimeNG Button Text Buttons Component. A Button component is used for carrying out some action
      3 min read

    • Angular PrimeNG Button Outlined Buttons Component
      Angular PrimeNG is an open-source front-end UI library that has many native Angular UI components which help developers to build a fast and scalable web solution. In this article, we will see Angular PrimeNG Button Outlined Buttons Component. A Button component is used for carrying out some action w
      3 min read

    • Angular PrimeNG Button Link Buttons Component
      Angular PrimeNG is an open-source front-end UI library that has many native Angular UI components which help developers to build a fast and scalable web solution. In this article, we will see Angular PrimeNG Button Link Buttons Component. A Button component is used for carrying out some action when
      3 min read

    • Angular PrimeNG Button Badges Component
      Angular PrimeNG is an open-source library that consists 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 be seeing Angular PrimeNG Button Badges Component. A Button component is used f
      3 min read

    • Angular PrimeNG Button ButtonSet Component
      Angular PrimeNG is an open-source library that consists 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 Angular PrimeNG Button ButtonSet Component. A Button Component is used to p
      3 min read

    • Angular PrimeNG Button Sizes
      Angular PrimeNG is an open-source library that consists 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 Angular PrimeNG Button Sizes. A Button is generally used for carrying out s
      3 min read

    • Angular PrimeNG Button Loading State Component
      Angular PrimeNG is an open-source front-end UI library that has many native Angular UI components which help developers to build a fast and scalable web solution. In this article, we will be seeing Angular PrimeNG Button Loading State Component. A Button component is used for carrying out some actio
      3 min read

    • Angular PrimeNG Button Properties of pButton
      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 style the Tooltip component in Angular PrimeNG. A Button is general
      4 min read

    • Angular PrimeNG Button Properties of p-button
      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 style the Tooltip component in Angular PrimeNG. A Button is general
      5 min read

    • Angular PrimeNG Button Templates
      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 style the Tooltip component in Angular PrimeNG. A Button is general
      3 min read

    • Angular PrimeNG Button Styling
      Angular PrimeNG is a UI component library for Angular Applications. It offers many pre-built themes and UI components for a variety of tasks like inputs, menus, charts, Buttons, etc. In this article, we will be seeing the Button Styling in Angular PrimeNG. The Button component in PrimeNG is used to
      3 min read

    SplitButton Component

    • Angular PrimeNG SplitButton Animation Configuration
      Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. In this article, we will see how to use the SplitButton Animation Configuration Component in Angular PrimeNG.  The SplitButton Componen
      3 min read

    • Angular PrimeNG MenuModel API MenuItem
      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 Angular PrimeNG MenuModel API MenuItem. MenuModel API: Prime
      3 min read

    • Angular PrimeNG SplitButton Events
      Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. In this article, we will see how to use SplitButton Events in angular primeNG. The SplitButton component is used to make a button a dro
      3 min read

    • Angular PrimeNG SplitButton Severity
      Angular PrimeNG is an open-source library that consists 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 be seeing Angular PrimeNG SplitButton Severity. The SplitButton component combi
      4 min read

    • Angular PrimeNG SplitButton Raised and Rounded Buttons Component
      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. In this article, we will see the SplitButton Raised and Rounded Component in Angular PrimeNG. The SplitButton component is used to
      4 min read

    • Angular PrimeNG SplitButton Styling
      Angular PrimeNG is a framework used with angular to create components with great styling this framework is very easy to use and is used to make responsive websites. In this article, we will see Angular PrimeNG SplitButton Styling. The SplitButton component is used to make a button a dropdown. This c
      3 min read

    Speed Dial Component

    • Angular PrimeNG Speed Dial Type
      Angular PrimeNG is an open-source library that consists 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 be discussing Angular PrimeNG Speed Dial Type. The Speed Dial component display
      4 min read

    • Angular PrimeNG Speed Dial Linear
      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 SpeedDial Linear Component in Angular PrimeNG. We will
      4 min read

    • Angular PrimeNG Speed Dial Circle, Semi-Circle and Quarter-Circle
      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 Speed Dial Circle, Semi-Circle, and Quarter-Circle Com
      4 min read

    • Angular PrimeNG Speed Dial Tooltip Component
      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 SpeedDial Tooltip Component in Angular PrimeNG. We wil
      4 min read

    • Angular PrimeNG Speed Dial Transition Duration, Icon and No Rotate Animation
      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 SpeedDial Transition Duration, Icon and No Rotate Anim
      4 min read

    • Angular PrimeNG Speed Dial Mask
      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 SpeedDial Mask Component in Angular PrimeNG. We will a
      4 min read

    • Angular PrimeNG Speed Dial Direction
      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 SpeedDial Direction Component in Angular PrimeNG. We w
      4 min read

    • Angular PrimeNG Speed Dial 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 the SpeedDial Properties in Angular PrimeNG. The SpeedDial C
      5 min read

    • Angular PrimeNG Speed Dial Templates
      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 about Angular PrimeNG Speed Dial Templates. The SpeedDial Component i
      3 min read

    • Angular PrimeNG Speed Dial Events
      Angular PrimeNG is an open-source library that consists 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 be seeing Angular PrimeNG Speed Dial Events. The Speed Dial component displays
      4 min read

    • Angular PrimeNG Speed Dial Styling
      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 about Angular PrimeNG Speed Dial Styling. The SpeedDial Component is
      3 min read

geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences