Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recognize when angular bootstrap dropdown-menu is closed

Is there a way to recognize that angular-bootstrap dropdown-menu is closed? I want to recognize this event and run specific function.

<div class="btn-group" dropdown is-open="status.isopen">
  <button type="button" class="btn btn-primary dropdown-toggle" dropdown-toggle ng-disabled="disabled">
    Button dropdown <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> 
like image 761
orikoko Avatar asked Dec 11 '14 10:12

orikoko


1 Answers

Add to your parent div an on-toggle event

<div class="btn-group" dropdown is-open="status.isopen" on-toggle="toggled(open)">

And handle it witin the controller

$scope.toggled = function(open) {
    if (open) {
        console.log('is open');
    } else console.log('close');
}
like image 123
Ben Diamant Avatar answered Nov 15 '22 09:11

Ben Diamant