输入中的 ngBlur 与该输入框中搜索的列表项之间的问​​题

Problems between ngBlur in a input and the list items from a search in that input box

我有一个带有输入标签的搜索框,然后是一个包含用于搜索输入文本的选项的有序列表。

输入已关联 ngBlur 指令,用于清理搜索框并关闭建议项目列表。

我的问题是当我想点击一个项目时,它应该重定向到一个描述页面,但是 ngBlur 首先检测输入之外的事件并关闭所有内容。

<input class="search-box" ng-blur="closeSearch()">
<ul ng-repeat="product in products">
<li>{{product.name}}</li>
</ul>

结构就是这样的。有人对此有解决方案吗?

我不知道这是否是最好的方法,但我设法使用超时和布尔值来处理 ng-blur:

 $scope.stopPropagation = false;

  $scope.click = function() {
    alert("click");
    $scope.stopPropagation = true;
  }

  $scope.change = function() {
    $timeout(function() {
      if (!$scope.stopPropagation)
        $scope.filter = "asdasd";

      $scope.stopPropagation = false;
    }, 125);
  }

这里我把字符串 "asdasd" 放在函数更改(由 ng-blur 触发)中以获得结果。我在 125 毫秒后应用更改,以便在删除列表中的数据之前触发点击功能。

Link: http://codepen.io/armellajuan/pen/qbNdVp