Components: How to open a particular menu programmatically if more than one menu element?

Created on 27 Dec 2016  路  10Comments  路  Source: angular/components

If I have more than one menu element in a page, how will I open a particular menu based on the context or how can I select a menu element using ViewChild by specifying the name?

Plunker: https://plnkr.co/edit/iVgoBU?p=preview

All 10 comments

@crisbeto What could be done for this kind of scenario?

I couldn't got your question, what would you like to achieve?

https://plnkr.co/edit/gbpvuno5thiUzlYNIcb3?p=preview
In the example, how will I open the second menu when I click on the "open second menu button"?.

So you can do something like that:
https://plnkr.co/edit/ScrbSJQWkAdjaAI7EKQU?p=preview
The better approach would be using a query selector

  @ViewChild('trial') trigger: MdMenuTrigger;

But i'm getting the mdButton directive instead of the trigger, i will check what we can do with that.

Thanks @EladBezalel . Will wait for the update.
I got the same result when I tried with the first plnkr sample.
At times we cannot rely on the index and need to find out the controls by name.

Perfect. @EladBezalel Thanks for the help.

How do we assign mdMenuTriggerFor dynamically ?

[mdMenuTriggerFor]="link.menuName"

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

Related issues

crutchcorn picture crutchcorn  路  3Comments

Hiblton picture Hiblton  路  3Comments

dzrust picture dzrust  路  3Comments

MurhafSousli picture MurhafSousli  路  3Comments

jelbourn picture jelbourn  路  3Comments