我正在尝试在下拉列表中添加Datepicker,如下所示并设置了autoClose =“outsideClick”。但是,当按下任何月份按钮时,它会切换下拉列表。怎么解决这个问题?
Html代码:
<div class="date-wrap pull-right" dropdown auto-close="outsideClick">
<button class="btn btn-info" dropdown-toggle>Date Picker</button>
<div class="dropdown-menu datepicker" role="menu">
<datepicker show-weeks="false" ng-model="dt"></datepicker>
</div>
</div>
答案 0 :(得分:7)
您需要手动阻止点击事件冒泡,因此它永远不会到达关闭下拉列表的最顶层节点(文档):
<div class="date-wrap pull-right" dropdown auto-close="outsideClick">
<button class="btn btn-info" dropdown-toggle>Date Picker</button>
<div class="dropdown-menu datepicker" role="menu" ng-click="$event.stopPropagation()">
<datepicker show-weeks="false" ng-model="dt"></datepicker>
</div>
</div>
注意,ng-click="$event.stopPropagation()"
可以解决问题。