我正在尝试使用附加的下拉菜单构建搜索输入。当输入框失去焦点时,我已将菜单设置为关闭。
问题:当我点击下拉菜单中的链接时,即使在注册任何事件之前菜单也会关闭。
// Search input box
<input type="text" ng-blur="lostFocus()" eva-search />
// Dropdown menu
<div class="component-styleWrap"
ng-click="$event.stopImmediatePropagation(); $event.stopPropagation()">
<li>Example Link</li>
<li>Example Link</li>
</div>
答案 0 :(得分:0)
如果您只想延迟调用lostFocus()的效果,那么超时就足够了。
app.controller("myController", function ($scope, $timeout) {
$scope.lostFocus = function () {
$timeout(function () {
//whatever your code needs to do goes here.
}, 100);
});
});
你不应该真的需要100。我刚才补充说,为了安全起见。如果可以,请尝试不使用100。