Skip to content

[mat-menu] Passing in data to a menu - mistake in documentation/example #9944

@martinpreky

Description

@martinpreky

Bug, feature request, or proposal:

Bug - mistake in documentation for material.angular.io

What is the expected behavior?

Working according to documentation/example.

What is the current behavior?

This example:
https://material.angular.io/components/menu/overview#passing-in-data-to-a-menu

is not working, throws error
"Template parse errors: "let-" is only supported on ng-template elements."

What are the steps to reproduce?

https://stackblitz.com/edit/angular-rlfbhk

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

... i think motivation is obvious. There is a malfunctioned example in documentation.

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

all

Is there anything else we should know?

working example is here, at the very bottom in .spec
https://github.com/angular/material2/blob/master/src/lib/menu/menu.spec.ts

<button
     [matMenuTriggerFor]="menu"
     [matMenuTriggerData]="{label: 'one'}"
     #triggerOne="matMenuTrigger">One</button>
<button
     [matMenuTriggerFor]="menu"
     [matMenuTriggerData]="{label: 'two'}"
     #triggerTwo="matMenuTrigger">Two</button>
<mat-menu matMenuContent #menu="matMenu">
     <ng-template let-label="label" matMenuContent>
       <button mat-menu-item>{{label}}</button>
     </ng-template>
</mat-menu>

Current documentation is here:
https://github.com/angular/material2/blob/master/src/lib/menu/menu.md

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functionsdocsThis issue is related to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions