We can also include menus inside another menu as much as we want.
To begin, add the MatMenuModule to the project. Go to the app component TypeScript file, add the import statement, and add it to the app.
Creating the Menu
To create the menu, use the mat-menu element Go into a HTML file and add it to the page.
<mat-menu>
Then to the add menu items, add a button element for each item and then apply the mat-menu-item property to each button.
<mat-menu>
Lastly, give the menu a template reference.
<mat-menu #mainMenu>
<button [matMenuTriggerFor]="mainMenu">Menu Example Trigger</button>
Nested Menus
<mat-menu #subMenu>
<mat-menu #mainMenu>
Positioning the Menu
<mat-menu #mainMenu overlapTrigger>
To place the menu above the element, apply the yPosition attribute to the menu and set it to above.
<mat-menu #mainMenu yPosition="above">
Lastly, to place the menu at the end of the element, we use xPosition and set it to before.
<mat-menu #mainMenu xPosition="before">