1
1
# md-menu
2
2
3
- ` md-menu ` is a list of options that displays when triggered. You can read more about menus in the
3
+ ` md-menu ` is a list of options that displays when triggered. You can read more about menus in the
4
4
[ Material Design spec] ( https://material.google.com/components/menus.html ) .
5
5
6
6
### Not yet implemented
13
13
14
14
### Simple menu
15
15
16
- In your template, create an ` md-menu ` element. You can use either ` <button> ` or ` <anchor> ` tags for
17
- your menu items, as long as each is tagged with an ` md-menu-item ` attribute. Note that you can
16
+ In your template, create an ` md-menu ` element. You can use either ` <button> ` or ` <anchor> ` tags for
17
+ your menu items, as long as each is tagged with an ` md-menu-item ` attribute. Note that you can
18
18
disable items by adding the ` disabled ` boolean attribute or binding to it.
19
19
20
20
* my-comp.html*
@@ -28,15 +28,15 @@ disable items by adding the `disabled` boolean attribute or binding to it.
28
28
</md-menu >
29
29
```
30
30
31
- Menus are hidden by default, so you'll want to connect up a menu trigger that can open your menu.
32
- You can do so by adding a button tag with an ` md-menu-trigger-for ` attribute and passing in the menu
33
- instance. You can create a local reference to your menu instance by adding ` #menu="mdMenu" ` to
31
+ Menus are hidden by default, so you'll want to connect up a menu trigger that can open your menu.
32
+ You can do so by adding a button tag with an ` mdMenuTriggerFor ` attribute and passing in the menu
33
+ instance. You can create a local reference to your menu instance by adding ` #menu="mdMenu" ` to
34
34
your menu element.
35
35
36
36
* my-comp.html*
37
37
``` html
38
38
<!-- menu opens when trigger button is clicked -->
39
- <button md-icon-button [md-menu-trigger-for ] =" menu" >
39
+ <button md-icon-button [mdMenuTriggerFor ] =" menu" >
40
40
<md-icon >more_vert</md-icon >
41
41
</button >
42
42
@@ -55,10 +55,10 @@ Output:
55
55
56
56
### Toggling the menu programmatically
57
57
58
- You can also use the menu's API to open or close the menu programmatically from your class. Please
59
- note that in this case, an ` md-menu-trigger-for ` attribute is still necessary to connect
58
+ You can also use the menu's API to open or close the menu programmatically from your class. Please
59
+ note that in this case, an ` mdMenuTriggerFor ` attribute is still necessary to connect
60
60
the menu to its trigger element in the DOM.
61
-
61
+
62
62
* my-comp.component.ts*
63
63
``` ts
64
64
class MyComp {
@@ -72,7 +72,7 @@ class MyComp {
72
72
73
73
* my-comp.html*
74
74
``` html
75
- <button md-icon-button [md-menu-trigger-for ] =" menu" >
75
+ <button md-icon-button [mdMenuTriggerFor ] =" menu" >
76
76
<md-icon >more_vert</md-icon >
77
77
</button >
78
78
@@ -91,15 +91,15 @@ Menus also support displaying `md-icon` elements before the menu item text.
91
91
* my-comp.html*
92
92
``` html
93
93
<md-menu #menu =" mdMenu" >
94
- <button md-menu-item >
94
+ <button md-menu-item >
95
95
<md-icon > dialpad </md-icon >
96
96
<span > Redial </span >
97
97
</button >
98
- <button md-menu-item disabled >
98
+ <button md-menu-item disabled >
99
99
<md-icon > voicemail </md-icon >
100
100
<span > Check voicemail </span >
101
101
</button >
102
- <button md-menu-item >
102
+ <button md-menu-item >
103
103
<md-icon > notifications_off </md-icon >
104
104
<span > Disable alerts </span >
105
105
</button >
@@ -114,8 +114,8 @@ Output:
114
114
115
115
### Customizing menu position
116
116
117
- By default, the menu will display after and below its trigger. You can change this display position
118
- using the ` x-position ` (` before | after ` ) and ` y-position ` (` above | below ` ) attributes.
117
+ By default, the menu will display after and below its trigger. You can change this display position
118
+ using the ` x-position ` (` before | after ` ) and ` y-position ` (` above | below ` ) attributes.
119
119
120
120
* my-comp.html*
121
121
``` html
@@ -134,7 +134,7 @@ Output:
134
134
135
135
### Accessibility
136
136
137
- The menu adds ` role="menu" ` to the main menu element and ` role="menuitem" ` to each menu item. It
137
+ The menu adds ` role="menu" ` to the main menu element and ` role="menuitem" ` to each menu item. It
138
138
also adds ` aria-hasPopup="true" ` to the trigger element.
139
139
140
140
#### Keyboard events:
@@ -146,26 +146,26 @@ also adds `aria-hasPopup="true"` to the trigger element.
146
146
147
147
| Signature | Values | Description |
148
148
| --- | --- | --- |
149
- | ` x-position ` | `before | after` | The horizontal position of the menu in relation to the trigger. Defaults to ` after ` . |
149
+ | ` x-position ` | `before | after` | The horizontal position of the menu in relation to the trigger. Defaults to ` after ` . |
150
150
| ` y-position ` | `above | below` | The vertical position of the menu in relation to the trigger. Defaults to ` below ` . |
151
-
151
+
152
152
### Trigger Programmatic API
153
153
154
154
** Properties**
155
155
156
156
| Name | Type | Description |
157
157
| --- | --- | --- |
158
- | ` menuOpen ` | ` Boolean ` | Property that is true when the menu is open. It is not settable (use methods below). |
159
- | ` onMenuOpen ` | ` Observable<void> ` | Observable that emits when the menu opens. |
160
- | ` onMenuClose ` | ` Observable<void> ` | Observable that emits when the menu closes. |
158
+ | ` menuOpen ` | ` Boolean ` | Property that is true when the menu is open. It is not settable (use methods below). |
159
+ | ` onMenuOpen ` | ` Observable<void> ` | Observable that emits when the menu opens. |
160
+ | ` onMenuClose ` | ` Observable<void> ` | Observable that emits when the menu closes. |
161
161
162
162
** Methods**
163
163
164
164
| Method | Returns | Description |
165
165
| --- | --- | --- |
166
166
| ` openMenu() ` | ` Promise<void> ` | Opens the menu. Returns a promise that will resolve when the menu has opened. |
167
167
| ` closeMenu() ` | ` Promise<void> ` | Closes the menu. Returns a promise that will resolve when the menu has closed. |
168
- | ` toggleMenu() ` | ` Promise<void> ` | Toggles the menu. Returns a promise that will resolve when the menu has completed opening or closing. |
169
- | ` destroyMenu() ` | ` Promise<void> ` | Destroys the menu overlay completely.
170
-
168
+ | ` toggleMenu() ` | ` Promise<void> ` | Toggles the menu. Returns a promise that will resolve when the menu has completed opening or closing. |
169
+ | ` destroyMenu() ` | ` Promise<void> ` | Destroys the menu overlay completely.
170
+
171
171
0 commit comments