我有一个在我的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>
解决方法
尝试
1)分配一些id或类
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);
}