gpt4 book ai didi

javascript - 如何在 md-select 内单击按钮时关闭 md-select?

转载 作者:行者123 更新时间:2023-11-28 04:33:24 25 4
gpt4 key购买 nike

如何在 md-select 窗口内单击按钮时关闭 md-select?

JS

$scope.closeSelectBox = () => {
var esc = jQuery.Event("keydown");
esc.which = 27
esc.keyCode = 27
$(document).trigger(esc)
}

HTML

<md-input-container style="max-width: 150px; width: 150">
<label>Helper:</label>
<md-select ng-model='vm.selectedHelpers' multiple>
<md-select-header style="height: 25px">
<md-button ng-click="closeSelectBox()">Close</md-button>
</md-select-header>
<md-option ng-repeat='item in vm.helpers' ng-value='item'>
{{item.name}}
</md-option>
</md-select>
</md-input-container>

jsFiddle

最佳答案

已解决只需要触发点击 md-backdrop

$("md-backdrop").trigger ("click")

Working Fiddle

关于javascript - 如何在 md-select 内单击按钮时关闭 md-select?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44437202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com