Skip to content

docs(menu): add live example of menu position #15591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/menu/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ The position can be changed using the `xPosition` (`before | after`) and `yPosit
</button>
```

<!-- example(menu-position) -->

### Nested menu

Material supports the ability for an `mat-menu-item` to open a sub-menu. To do so, you have to define
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/** No CSS for this example */
24 changes: 24 additions & 0 deletions src/material-examples/menu-position/menu-position-example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<button mat-button [matMenuTriggerFor]="aboveMenu">Above</button>
<mat-menu #aboveMenu="matMenu" yPosition="above">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>

<button mat-button [matMenuTriggerFor]="belowMenu">Below</button>
<mat-menu #belowMenu="matMenu" yPosition="below">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>

<button mat-button [matMenuTriggerFor]="beforeMenu">Before</button>
<mat-menu #beforeMenu="matMenu" xPosition="before">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>


<button mat-button [matMenuTriggerFor]="afterMenu">After</button>
<mat-menu #afterMenu="matMenu" xPosition="after">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
11 changes: 11 additions & 0 deletions src/material-examples/menu-position/menu-position-example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {Component} from '@angular/core';

/**
* @title Menu positioning
*/
@Component({
selector: 'menu-position-example',
templateUrl: 'menu-position-example.html',
styleUrls: ['menu-position-example.css'],
})
export class MenuPositionExample {}