angularjs - Angular-UI run dropdownToggle from ng-click -
is there way run dropdowntoggle ng-click directive ? using ngmobile avoid delayed click of "actions" button on touch devices.
<div class="btn-group"> <a class="btn dropdown-toggle"> actions <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a>action 1</a></li> <li><a>action 2</a></li> </ul> </div>
there problem menu, doesn't close on tap if don't keep action1/action2 pressed long time. (much longer usual tap).
looks found solution (not best 1 assume) works. if has better one, please share.
opening dropdown adds "open" class dropdown element, in order opened on using ng-click needed add class.
i know it's temporary solution didn't find better one.
here's code:
<div class="btn-group" ng-class="{open: opened}" ng-click="opened=!opened" ng-init="opened=false"> <a class="btn dropdown-toggle"> actions <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a ng-click="$location.path('/some/addr')">action 1</a></li> </ul> </div>
as closing menu on click: caused error in html (not closing tag). after correction, problem disappeared. source see dropdown menu closed on both click & running $location.path()
Comments
Post a Comment