我的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()中需要什么。有什么想法吗?
答案 0 :(得分:1)
试 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);
}