Real-World Success Stories of Azure AI Foundry
AI is everywhere now. Companies use it to handle customer questions, process accounts and even make real decisions that professionals used to spend hours on. What took days now happens...
Kapil Panchal - August 18, 2021
Listening is fun too.
Straighten your back and cherish with coffee - PLAY !
The Angular Material Menu component is used to display a menu with several menu items which can be used to navigate from one page to another. Well, it's a simple floating menu that contains various menu selections with appropriate links to the application's various pages. We can also use menus inside toolbars, drawers, and footers depending on the project requirements.
In this article, we will construct a menu with many options, that will be quickly explained below.
The Material menu is a floating panel containing a list of options.
In Angular, we may apply the MatMenuModule angular material menu module to build menu items.
The element does not render anything on its own.
A material menu module can be included in our components ts file, app.module.ts file, and any other common material module used throughout the application.
import { MatMenuModule } from "@angular/material/menu";
[app.module.ts]
Step:2: Use a mat menu selector to display menu itemsUse mat-menu selector, which is nothing more than a floating panel containing a list of menu selections, after importing MatMenuModule in our component code.
[app.component.html]
As a Menu Item, I'm using the button element.
And do not forget to add mat-menu-item to the menu options.
In the mat-menu variable, add a template reference variable which will be used to refer to our menu panel.
In this scenario, I've included the variable menu.
[app.component.html]
Step:3 : Add matMenuTriggerFor element.The above mat-menu element has no render on the user interface.
The mat-menu is a directive that is used to trigger the menu options when the button click event is triggered because it cannot open menu items by itself.
The menu should be tied to a trigger element that uses the matMenuTriggerFor directive to open and shut the menu.
Simple menu:[app.component.html]
The material menu will be displayed by default above the menu trigger element.
If you want the menu to display before or after the menu trigger element, set the xPosition value to "before" or "after."
Set the xPosition value to "before" or "after" if you just want the menu to appear before or after the menu trigger element.
The xPosition attribute sets the menu all along the horizontal axis.
The yPosition attribute is used to change the menu's vertical position.
Set the yPosition property to "above" to display the menu just above the menu trigger element.
The values "above" and "below" are accepted by yPosition.
[app.component.html]
The disabled property can be used to disable the mat menu item.
I've added a property called IsDisabled to the MatMenuListItem object described above. It can also be used to turn off the menu link.
[app.component.html]
In this example, I'll use one menu with an icon;
We developed a simple menu in our previous example, but we can also use different material icons with menu and menu items in this example. Simply follow the instructions outlined below to accomplish this.
I'm going to use various material icons in this example, so we'll need a style sheet like this.
!doctype>
[index.html]
In this file, we have added a style sheet file to use different material icons throughout the application.
Clothes Shop more_vert !doctype>
[app.component.html]
In this article, we have learned how to integrate a material menu component with our Angular application with step by step procedure. We have also gone through changing the position of mat menu, how to enable and disable it practically.
AI is everywhere now. Companies use it to handle customer questions, process accounts and even make real decisions that professionals used to spend hours on. What took days now happens...
Azure Managed Services is a massive hub, and inside this, you've got everything from Virtual Machines, Azure SQL Databases, App Services, to Kubernetes, and even Azure Entra ID. It’s...
Microsoft Azure is really taking off! Companies like Ford, Intel, and Walmart, which are a part of the Fortune 500, are investing $1.2 to $24 million annually in Azure cloud services. The main reason is its amazing infrastructure and impressive scalability.