use mat-menu with dynamic data
Bug, feature request, or proposal:
request
What is the expected behavior?
I want to create a menu use this array:
[
{
label: '1.test1',
value: '1.test1',
child: {
name: 'child1',
value: [
{
label: '2.test1',
value: '2.test1',
child: {
name: 'child2',
value: [
{
label: '3.test1',
value: '3.test1',
},
{
label: '3.test2',
value: '3.test2',
},
]
}
},
{
label: '2.test1',
value: '2.test1',
},
]
}
},
{
label: '1.test2',
value: '1.test2'
},
];
What is the current behavior?
mat-menu accept items for connect to subMenu,eg:
<mat-menu #animals="matMenu">
<button mat-menu-item [matMenuTriggerFor]="secondMenu">1</button>
<button mat-menu-item >2</button>
<mat-menu #secondMenu="matMenu">
<button mat-menu-item [matMenuTriggerFor]="thirdMenu">1</button>
<button mat-menu-item>2</button>
<mat-menu #thirdMenu="matMenu">
<button mat-menu-item>3</button>
</mat-menu>
</mat-menu>
</mat-menu>
can't set secondMenu with dynamic data.
What are the steps to reproduce?
Providing a StackBlitz/Plunker (or similar) is the best way to get the team to see your issue.
Plunker starter (using on @master): https://goo.gl/uDmqyY
StackBlitz starter (using latest npm release): https://goo.gl/wwnhMV
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular: 5.0.0 Material: 5.0.0-rc0 TypeScript: 2.4.2
Is there anything else we should know?
Have you plan to create cascader component like this.
Make good Json structure.After you can use ngFor. It's better you can post this in StackOverflow. https://plnkr.co/edit/lpLxHlKtwCJUukoruxq2?p=preview -> sample solution
Please keep GitHub issues for bug reports / feature requests. Better avenues for troubleshooting / questions are stack overflow, gitter, mailing list, etc.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.