Skip to content

Nested md-menu with md-menu-items using *ngFor throws error #6765

@isaacplmann

Description

@isaacplmann

Bug, feature request, or proposal:

Creating a nested md-menu that uses *ngFor to generate the md-menu-items throws an error.

<md-menu #menu="mdMenu">
  <button *ngFor="let item of items" md-menu-item [mdMenuTriggerFor]="subMenu">
    ...
  </button>
</md-menu>

What is the expected behavior?

There is no error.

What is the current behavior?

An error is thrown when the nest md-menu is rendered on the page. (The files/line numbers are obviously wrong in this error message.)

app.component.html:19 ERROR TypeError: Cannot read property 'map' of undefined
    at MdMenu.hover (dialog.ts:69)
    at MdMenuTrigger.ngAfterViewInit (dialog-content-directives.ts:20)
    at callProviderLifecycles (query.ts:1)
    at callElementProvidersLifecycles (provider.ts:619)
    at callLifecycleHooksChildrenFirst (provider.ts:603)
    at checkAndUpdateView (view.ts:413)
    at callViewAction (view.ts:767)
    at execEmbeddedViewsAction (view.ts:726)
    at checkAndUpdateView (view.ts:410)
    at callViewAction (view.ts:767)
    at execComponentViewsAction (view.ts:700)
    at checkAndUpdateView (view.ts:413)
    at callWithDebugContext (services.ts:815)
    at Object.debugCheckAndUpdateView [as checkAndUpdateView] (services.ts:385)
    at ViewRef_.detectChanges (refs.ts:441)

What are the steps to reproduce?

Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://goo.gl/DlHd6U
http://plnkr.co/edit/qtGoBwyWQ4uICDR83No7?p=preview

What is the use-case or motivation for changing an existing behavior?

Need to be able to dynamically create nested menus.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular 4.3.6
Material 2.0.0-beta.10

Is there anything else we should know?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions