当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - 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>

网友答案:

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');
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: