Components: md-menu binding # dynamic

Created on 7 Jan 2017  Â·  9Comments  Â·  Source: angular/components

Hi all,
I want to assign the md-menu trigger action as the code below, but failed. Can you guide me?

  <div *ngFor="let menuItem of mainMenu">
   <div ng-if="menuItem.item.length > 0">
    <button md-button [mdMenuTriggerFor]="menuItem.mdMenuTriggerFor">
     <md-icon svgIcon="{{menuItem.icon}}"></md-icon>
     <span>{{menuItem.title}}</span>   
    </button>
    <md-menu {{menuItem.mdMenuTriggerFor}}="mdMenu">
     <div *ngFor="let item of menuItem.item">
      <button md-menu-item routerLink="{{item.routerLink}}">
       <md-icon svgIcon="{{item.icon}}"></md-icon>
       <span>{{item.title}}</span>
      </button>
     </div>
    </md-menu>
   </div>
   <div ng-if="menuItem.item.length == 0">
    <button md-button routerLink="{{menuItem.routerLink}}">
     <md-icon ng-if="menuItem.icon.length != 0" svgIcon="{{MenuItem.icon}}"></md-icon>
     <span>{{menuItem.title}}</span>   
    </button>
   </div>

Most helpful comment

What was the fix? I'm having this problem too.

All 9 comments

Closed

What was the fix? I'm having this problem too.

@EladBezalel Could you please give me some examples? I have the same problem.

I binding with same ref name.

On Tue, Jan 24, 2017, 9:43 AM Brandon Yang notifications@github.com wrote:

@EladBezalel https://github.com/EladBezalel Could you please give me
some examples? I have the same problem.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/angular/material2/issues/2559#issuecomment-274685545,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AH3p8EaKgGu1FDGLNgZbRBcPQE99qm0qks5rVWVpgaJpZM4LdWCz
.

@loongdefect I write the code in Plunker but failed. Could you please help me?
http://plnkr.co/edit/qRB9rT

display correct

<div *ngFor="let menuItem of menus">
    <button md-button [mdMenuTriggerFor]="menu">
       <span>{{menuItem.title}}</span>
    </button>
    <md-menu #menu="mdMenu">
      <button md-menu-item>Refresh - {{menuItem.title}}</button>
      <button md-menu-item>Settings - {{menuItem.title}}</button>
    </md-menu>
</div>

Only first button is working via this example @loongdefect

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._

Was this page helpful?
0 / 5 - 0 ratings