How to implement click function using angular js button in dropdown menu

I want to use the dropdown button in my application, and I use angularjs. When I click the drop-down button and click, I want the drop-down list to disappear.

Angular has a directive for this ng-blur. I added ng-blur to my button. When I click on something in the dropdown, it seems to call ng-blur.

I can not click on the whole drop-down list. I tried adding a div outside and adding ng-blur for all this div, but it still doesn't work. I do not use angularstrap bs-select, ng-options, since I want to do datacalls when I select from the drop-down list. How can I implement the click function for a dropdown button? It is not necessary to use ng-blur. Thank you

<div class="btn-group">
   <button type="button" class="btn btn-default" ng-blur="closedropdownlist">Default</button>
      <span class="caret"></span>
   </button>
   <ul class="dropdown-menu" role="menu">
      <li><a href="#">Action</a></li>
      <li><a href="#">Another action</a></li>
      <li><a href="#">Something else here</a></li>
      <li class="divider"></li>
      <li><a href="#">Separated link</a></li>
   </ul>
</div>
Run code

Here's a Plunker demo for him, http://plnkr.co/edit/OuiZqajYD3ZdrOwSLLSn?p=preview I would like the dropdown to disappear when I click the dropdown button. I also want to enable the ng-click function inside the dropdown list. Therefore, I do not use ng-options and ng-model.

+4
source share
1 answer

stackoverflow: ng-blur ui-sref , , click blur, click , ng-mousedown, blur. .

+1

All Articles