angularjs – 从按钮打开触发菜单

我有一个在我的html中定义的菜单:

 <md-menu>
 <!-- Trigger element is a md-button with an icon -->
    <md-button ng-click="$mdOpenMenu($event)" class="md-icon-button" aria-label="Open sample menu">
        <md-icon md-svg-icon="call:phone"></md-icon>
       </md-button>
    <md-menu-content>
        <md-menu-item><md-button ng-click="doSomething()">Do Something</md-button></md-menu-item>
    </md-menu-content>
</md-menu>

和同一个html上的其他地方的按钮:

<md-button ng-click="openOtherMenu()">Open Menu</md-button>

我想点击打开菜单按钮将触发菜单的打开.我不确定openOtherMenu()中需要什么.有任何想法吗?

最佳答案 尝试

1)分配一些id或类

  <md-button id='luis' ng-click="$mdOpenMenu($event)"

2)在你的控制器中

 .controller('yourcontroller',function($scope,$timeout){

$scope.openOtherMenu=function(){
   $timeout(function(){
     var ele=document.getElementById('luis');
     angular.element(ele).triggerHandler('click');
   },0);

}

点赞